nwb-linkml/nwb_linkml/tests/test_includes.py
2024-07-29 16:28:48 -07:00

20 lines
480 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"