Fix: Se descomenta test AttachedDocument
This commit is contained in:
		@@ -57,6 +57,7 @@ Bogota = tz.gettz('America/Bogota')
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
NAMESPACES = {
 | 
					NAMESPACES = {
 | 
				
			||||||
 | 
					    'atd': 'urn:oasis:names:specification:ubl:schema:xsd:AttachedDocument-2',
 | 
				
			||||||
    'fe': 'http://www.dian.gov.co/contratos/facturaelectronica/v1',
 | 
					    'fe': 'http://www.dian.gov.co/contratos/facturaelectronica/v1',
 | 
				
			||||||
    'cac': 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2',
 | 
					    'cac': 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2',
 | 
				
			||||||
    'cbc': 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2',
 | 
					    'cbc': 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2',
 | 
				
			||||||
@@ -106,17 +107,20 @@ class FeXML(FachoXML):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def tostring(self, **kw):
 | 
					    def tostring(self, **kw):
 | 
				
			||||||
        # MACHETE(bit4bit) la DIAN espera que la etiqueta raiz no este en un namespace
 | 
					        # MACHETE(bit4bit) la DIAN espera que la etiqueta raiz no este en un namespace
 | 
				
			||||||
 | 
					        urn_oasis = {
 | 
				
			||||||
 | 
					            'AttachedDocument': 'urn:oasis:names:specification:ubl:schema:xsd:AttachedDocument-2',
 | 
				
			||||||
 | 
					            'Invoice': 'urn:oasis:names:specification:ubl:schema:xsd:Invoice-2',
 | 
				
			||||||
 | 
					            'CreditNote': 'urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2',
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        root_namespace = self.root_namespace()
 | 
					        root_namespace = self.root_namespace()
 | 
				
			||||||
        root_localname = self.root_localname()
 | 
					        root_localname = self.root_localname()
 | 
				
			||||||
        xmlns_name = {v: k for k, v in NAMESPACES.items()}[root_namespace]
 | 
					        xmlns_name = {v: k for k, v in NAMESPACES.items()}[root_namespace]
 | 
				
			||||||
        if root_localname == 'Invoice':
 | 
					
 | 
				
			||||||
            urn_oasis = 'urn:oasis:names:specification:ubl:schema:xsd:Invoice-2'
 | 
					 | 
				
			||||||
        if root_localname == 'CreditNote':
 | 
					 | 
				
			||||||
            urn_oasis = 'urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2'
 | 
					 | 
				
			||||||
        return super().tostring(**kw)\
 | 
					        return super().tostring(**kw)\
 | 
				
			||||||
                        .replace(xmlns_name + ':', '')\
 | 
					                        .replace(xmlns_name + ':', '')\
 | 
				
			||||||
                        .replace('xmlns:'+xmlns_name, 'xmlns')\
 | 
					                        .replace('xmlns:'+xmlns_name, 'xmlns')\
 | 
				
			||||||
                        .replace(root_namespace, urn_oasis)
 | 
					                        .replace(root_namespace, urn_oasis[root_localname])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DianXMLExtensionCUDFE(FachoXMLExtension):
 | 
					class DianXMLExtensionCUDFE(FachoXMLExtension):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,13 +4,13 @@
 | 
				
			|||||||
# this repository contains the full copyright notices and license terms.
 | 
					# this repository contains the full copyright notices and license terms.
 | 
				
			||||||
# from datetime import datetime
 | 
					# from datetime import datetime
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# import pytest
 | 
					import pytest
 | 
				
			||||||
# from facho.fe import form_xml
 | 
					from facho.fe import form_xml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# import helpers
 | 
					import helpers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# def test_xml_with_required_elements():
 | 
					def test_xml_with_required_elements():
 | 
				
			||||||
#     doc = form_xml.AttachedDocument(id='123')
 | 
					    doc = form_xml.AttachedDocument(id='123')
 | 
				
			||||||
#     xml = doc.toFachoXML()
 | 
					    xml = doc.toFachoXML()
 | 
				
			||||||
#     assert xml.get_element_text('/atd:AttachedDocument/cbc:ID') == '123'
 | 
					    assert xml.get_element_text('/atd:AttachedDocument/cbc:ID') == '123'
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user