MCPcopy Create free account
hub / github.com/langroid/langroid / test_format_complex_nested

Function test_format_complex_nested

tests/main/test_xml_tool_message.py:423–461  ·  view source on GitHub ↗
(complex_nested_xml_tool: ComplexNestedXMLTool)

Source from the content-addressed store, hash-verified

421
422
423def test_format_complex_nested(complex_nested_xml_tool: ComplexNestedXMLTool):
424 complex_tool = complex_nested_xml_tool
425 formatted = complex_tool.format_example()
426 print(formatted) # For debugging
427 assert "<person>" in formatted
428 assert "<name>Jane Doe</name>" in formatted
429 assert "<age>28</age>" in formatted
430 assert "<address>" in formatted
431 # NOTE: street was declared as verbatim, so it should be in a CDATA section
432 assert "<street><![CDATA[456 Elm St]]></street>" in formatted
433 assert "<city>Somewhere</city>" in formatted
434 assert "<country>Canada</country>" in formatted
435 assert "<hobbies>" in formatted
436 assert "<item>painting</item>" in formatted
437 assert "<item>hiking</item>" in formatted
438 assert "<phones>" in formatted
439 assert "<mobile>5551234567</mobile>" in formatted
440 assert "<work>5559876543</work>" in formatted
441 assert "<friends>" in formatted
442 assert "<person>" in formatted
443 assert "<name>John Doe</name>" in formatted
444 assert "<age>30</age>" in formatted
445 assert "<name>Jack Doe</name>" in formatted
446 assert "<age>32</age>" in formatted
447
448 # Test case for absent friends field
449 complex_tool_no_friends = ComplexNestedXMLTool(
450 person=Person(
451 name="Alice Smith",
452 age=25,
453 address=Address(street="789 Pine St", city="Nowhere", country="USA"),
454 ),
455 hobbies=["reading", "swimming"],
456 phones={"home": 1234567890},
457 friends=None,
458 )
459 formatted_no_friends = complex_tool_no_friends.format_example()
460 print(formatted_no_friends) # For debugging
461 assert "<friends>" not in formatted_no_friends
462
463
464def test_parse_complex_nested():

Callers

nothing calls this directly

Calls 4

PersonClass · 0.85
AddressClass · 0.85
format_exampleMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…