facho/facho.py: maneja rutas relativas.

FossilOrigin-Name: cd97ead663dbbc1e2252f83da6e9cf17f9b3ae32e0ff411427ec62ad3658e89d
This commit is contained in:
2020-10-27 03:19:08 +00:00
parent cb366aa1c5
commit 1a2bd38b35
2 changed files with 28 additions and 3 deletions

View File

@@ -150,3 +150,23 @@ def test_facho_xml_get_element_text_next_child():
line = xml.fragment('/Invoice/Line', append=True)
line.set_element('/Line/Quantity', 6)
assert line.get_element_text('/Line[2]/Quantity', format_=int) == 6
def test_facho_xml_set_element_relative():
xml = facho.FachoXML('Invoice')
xml.set_element('./ID', 'ABC123')
assert xml.get_element_text('/Invoice/ID') == 'ABC123'
def test_facho_xml_set_element_relative_with_namespace():
xml = facho.FachoXML('{%s}Invoice' % ('http://www.dian.gov.co/contratos/facturaelectronica/v1'),
nsmap={'fe': 'http://www.dian.gov.co/contratos/facturaelectronica/v1'})
xml.set_element('./ID', 'ABC123')
assert xml.get_element_text('/fe:Invoice/ID') == 'ABC123'
def test_facho_xml_fragment_relative():
xml = facho.FachoXML('root')
invoice = xml.fragment('./Invoice')
invoice.set_element('./Id', 1)
assert xml.tostring() == '<root><Invoice><Id>1</Id></Invoice></root>'