Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drafthorse/models/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def to_etree(self):
return node

def from_etree(self, root, strict=True):
self._text = Decimal(root.text)
self._text = root.text
self._list_id = root.attrib["listID"]
self._list_version_id = root.attrib["listVersionID"]
self._set_on_input = True
Expand Down
22 changes: 22 additions & 0 deletions tests/test_classification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import xml.etree.ElementTree as ET

from drafthorse.models.product import ProductClassification

NS = "urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"


def _parse(code, list_id, version):
xml = (
f'<ram:DesignatedProductClassification xmlns:ram="{NS}">'
f'<ram:ClassCode listID="{list_id}" listVersionID="{version}">{code}</ram:ClassCode>'
"</ram:DesignatedProductClassification>"
)
return ProductClassification().from_etree(ET.fromstring(xml))


def test_class_code_keeps_the_original_text():
horses = _parse("010121", "HS", "2022")
assert str(horses.class_code) == "010121 (HS 2022)"

service = _parse("SRV", "ZZZ", "1")
assert str(service.class_code) == "SRV (ZZZ 1)"