MCPcopy Create free account
hub / github.com/ScrapeGraphAI/toonify / test_nested_models

Method test_nested_models

tests/test_pydantic.py:50–75  ·  view source on GitHub ↗

Test encoding nested Pydantic models.

(self)

Source from the content-addressed store, hash-verified

48 assert 'MOU-042,Wireless Mouse,29.99' in toon
49
50 def test_nested_models(self):
51 """Test encoding nested Pydantic models."""
52 class Address(BaseModel):
53 street: str
54 city: str
55 zipcode: str
56
57 class Person(BaseModel):
58 name: str
59 age: int
60 address: Address
61
62 person = Person(
63 name='Bob',
64 age=35,
65 address=Address(street='123 Main St', city='Boston', zipcode='02101')
66 )
67
68 toon = encode_pydantic(person)
69
70 assert 'name: Bob' in toon
71 assert 'age: 35' in toon
72 assert 'address:' in toon
73 assert 'street: 123 Main St' in toon
74 assert 'city: Boston' in toon
75 assert 'zipcode: 02101' in toon
76
77 def test_exclude_unset(self):
78 """Test excluding unset fields."""

Callers

nothing calls this directly

Calls 3

encode_pydanticFunction · 0.90
PersonClass · 0.70
AddressClass · 0.70

Tested by

no test coverage detected