Skip to content

Commit

Permalink
fix: remove pretty format internal xml
Browse files Browse the repository at this point in the history
The internal xml doesn't need to be formatted.
  • Loading branch information
igobranco committed Apr 9, 2024
1 parent a2cd5c6 commit 76ea6b5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion apps/billing/services/processor_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def __generate_data(self) -> str:
<TAB ID="SIH4_1">{items_as_xml}</TAB>
</PARAM>
"""
objectXML = self.__class__._pretty_format_xml(objectXML, space="\t")
# objectXML = self.__class__._pretty_format_xml(objectXML, space="\t")

data = f"""
<soapenv:Envelope
Expand Down
38 changes: 19 additions & 19 deletions apps/billing/tests/test_sagex3_processor_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,24 +264,24 @@ def test_data_processor_custom_series(self):
object_xml_root: ET.Element = self.__class__._get_xml_element_from_transaction(transaction)
self.assertEqual(object_xml_root.findall(".//*/FLD[@NAME='SIVTYP']")[0].text, "Some")

def test_data_object_xml_is_formatted(self):
"""
Test the SageX3Processor for a custom series.
"""
transaction = TransactionFactory()
SageX3TransactionInformationFactory(transaction=transaction, series="Some")
xml = SageX3Processor(transaction).data
root = ET.fromstring(xml) # nosec
object_xml: str = root.findall(".//*/objectXml")[0].text.strip()

# pretty
element = ET.XML(object_xml)
ET.indent(element, space="\t")
pretty = ET.tostring(element, encoding="unicode")

param_idx = object_xml.index("<PARAM>")
object_xml_without_1st_line = object_xml[param_idx:]

self.assertEqual(object_xml_without_1st_line, pretty)
# def test_data_object_xml_is_formatted(self):
# """
# Test the SageX3Processor for a custom series.
# """
# transaction = TransactionFactory()
# SageX3TransactionInformationFactory(transaction=transaction, series="Some")
# xml = SageX3Processor(transaction).data
# root = ET.fromstring(xml) # nosec
# object_xml: str = root.findall(".//*/objectXml")[0].text.strip()

# # pretty
# element = ET.XML(object_xml)
# ET.indent(element, space="\t")
# pretty = ET.tostring(element, encoding="unicode")

# param_idx = object_xml.index("<PARAM>")
# object_xml_without_1st_line = object_xml[param_idx:]

# self.assertEqual(object_xml_without_1st_line, pretty)

# TODO test each items

0 comments on commit 76ea6b5

Please sign in to comment.