mirror of
https://github.com/p2p-ld/nwb-linkml.git
synced 2024-11-14 02:34:28 +00:00
17 lines
No EOL
476 B
Python
17 lines
No EOL
476 B
Python
from pydantic import BaseModel
|
|
from nwb_linkml.includes import Named
|
|
|
|
def test_named_generic():
|
|
"""
|
|
the Named type should fill in the ``name`` field in a model from the field name
|
|
"""
|
|
class Child(BaseModel):
|
|
name: str
|
|
value: int
|
|
|
|
class Parent(BaseModel):
|
|
field_name: Named[Child]
|
|
|
|
# should instantiate correctly and have name set
|
|
instance = Parent(field_name={'value': 1})
|
|
assert instance.field_name.name == 'field_name' |