Test encoding and decoding round-trip.
(self)
| 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.""" |
nothing calls this directly
no test coverage detected