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

Method test_roundtrip

tests/test_pydantic.py:257–277  ·  view source on GitHub ↗

Test encoding and decoding round-trip.

(self)

Source from the content-addressed store, hash-verified

255 decode_to_pydantic("data: value", "not a class")
256
257 def test_roundtrip(self):
258 """Test encoding and decoding round-trip."""
259 class User(BaseModel):
260 id: int
261 name: str
262 email: str
263 active: bool
264
265 original = User(id=42, name='Charlie', email='charlie@example.com', active=True)
266
267 # Encode to TOON
268 toon = encode_pydantic(original)
269
270 # Decode back to Pydantic
271 decoded = decode_to_pydantic(toon, User)
272
273 # Verify equality
274 assert decoded.id == original.id
275 assert decoded.name == original.name
276 assert decoded.email == original.email
277 assert decoded.active == original.active
278
279 def test_list_roundtrip(self):
280 """Test encoding and decoding round-trip with list."""

Callers

nothing calls this directly

Calls 3

encode_pydanticFunction · 0.90
decode_to_pydanticFunction · 0.90
UserClass · 0.70

Tested by

no test coverage detected