se adicionan mas pruebas a facho xml

FossilOrigin-Name: 1425e28d9ca9a0025dacd40fc57fff5cf3bbf67d0fc8482899502b996a0d41f9
This commit is contained in:
bit4bit
2021-11-05 01:28:35 +00:00
parent 18342b7e23
commit c758912cf2
3 changed files with 70 additions and 15 deletions

View File

@@ -319,3 +319,35 @@ def test_facho_xml_fragment_create_on_first_append():
A = xml.fragment('./A', append=True)
A.find_or_create_element('./C')
assert xml.tostring() == '<root><A><B/></A><A><C/></A></root>'
def test_facho_xml_placeholder_optional_and_fragment():
xml = facho.FachoXML('root')
xml.placeholder_for('./A/AA')
A = xml.fragment('./A', append_not_exists=True)
A.find_or_create_element('./AA/B')
A = xml.fragment('./A', append_not_exists=True)
A.find_or_create_element('./AA/C')
assert xml.tostring() == '<root><A><AA><B/><C/></AA></A></root>'
def test_facho_xml_placeholder_optional_and_set_attributes():
xml = facho.FachoXML('root')
xml.placeholder_for('./A')
xml.set_attributes('/root/A', prueba='OK')
assert xml.get_element_attribute('/root/A', 'prueba') == 'OK'
assert xml.tostring() == '<root><A prueba="OK"/></root>'
def test_facho_xml_placeholder_optional_and_fragment_with_set_element():
xml = facho.FachoXML('root')
xml.placeholder_for('./A/AA')
A = xml.fragment('./A', append_not_exists=True)
A.set_element('./AA', None, append_=True, prueba='OK')
assert xml.tostring() == '<root><A><AA prueba="OK"/></A></root>'
assert xml.get_element_attribute('/root/A/AA', 'prueba') == 'OK'