mirror of
https://github.com/p2p-ld/nwb-linkml.git
synced 2024-11-14 10:44:28 +00:00
17 lines
476 B
Python
17 lines
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'
|