MCPcopy Index your code
hub / github.com/langroid/langroid / test_instructions_complex_nested

Function test_instructions_complex_nested

tests/main/test_xml_tool_message.py:501–540  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

499
500
501def test_instructions_complex_nested():
502 instructions = ComplexNestedXMLTool.format_instructions()
503 root_tag = ComplexNestedXMLTool._get_root_element()
504
505 assert "Placeholders:" in instructions
506 assert "REQUEST = [value for request]" in instructions
507 assert "PERSON = [nested structure for person]" in instructions
508 assert "NAME = [value for name]" in instructions
509 assert "AGE = [value for age]" in instructions
510 assert "ADDRESS = [nested structure for address]" in instructions
511 assert "STREET = [value for street]" in instructions
512 assert "CITY = [value for city]" in instructions
513 assert "COUNTRY = [value for country]" in instructions
514 assert "HOBBIES = [list of str for hobbies]" in instructions
515 assert "PHONES = [dictionary with str keys and int values]" in instructions
516 assert "FRIENDS = [list of nested structures for friends]" in instructions
517
518 assert "Formatting example:" in instructions
519 assert f"<{root_tag}>" in instructions
520 assert f"</{root_tag}>" in instructions
521 assert "<request>{REQUEST}</request>" in instructions
522 assert "<person>" in instructions
523 assert "<name>{NAME}</name>" in instructions
524 assert "<age>{AGE}</age>" in instructions
525 assert "<address>" in instructions
526 # NOTE: street was declared as verbatim, so it should be in a CDATA section
527 assert "<street><![CDATA[{STREET}]]></street>" in instructions
528 assert "<city>{CITY}</city>" in instructions
529 assert "<country>{COUNTRY}</country>" in instructions
530 assert "</address>" in instructions
531 assert "</person>" in instructions
532 assert "<hobbies>" in instructions
533 assert "<item>[str value]</item>" in instructions
534 assert "</hobbies>" in instructions
535 assert "<phones>" in instructions
536 assert "<str>[int value]</str>" in instructions
537 assert "</phones>" in instructions
538 assert "<friends>" in instructions
539 assert "<item>[Person value]</item>" in instructions
540 assert "</friends>" in instructions
541
542
543def test_roundtrip_complex_nested(complex_nested_xml_tool):

Callers

nothing calls this directly

Calls 2

_get_root_elementMethod · 0.80
format_instructionsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…