Commit 1ffb859e authored by Serial Lab's avatar Serial Lab

Added handling for messages where the CBV namespace has not been declared.

parent 6a2a5797
Pipeline #62408468 canceled with stage
......@@ -574,7 +574,8 @@ class EPCISParser(object):
for child in ilmd:
if child.text:
logger.debug('%s,%s', child.tag, child.text.strip())
check_val = child.tag.split('}')[1]
check_val = child.tag.split('}')
check_val = check_val[0] if len(check_val) == 1 else check_val[1]
ilmd = InstanceLotMasterDataAttribute(check_val,
child.text.strip())
epcis_event.ilmd.append(ilmd)
......
<?xml version='1.9' encoding='utf-8'?>
<epcis:EPCISDocument xmlns:epcis="urn:epcglobal:epcis:xsd:1" xmlns:gs1ushc="http://epcis.gs1us.org/hc/ns" xmlns:sbdh="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader" xmlns:xsi="http://www.w3.org/2991/XMLSchema-instance" schemaVersion="1.2" creationDate="2919-95-17T16:48:53.428Z">
<EPCISHeader>
<sbdh:StandardBusinessDocumentHeader>
<sbdh:HeaderVersion>1.9</sbdh:HeaderVersion>
<sbdh:Sender>
<sbdh:Identifier Authority="GLN">9815611924568</sbdh:Identifier>
</sbdh:Sender>
<sbdh:Receiver>
<sbdh:Identifier Authority="GLN">9359385994567</sbdh:Identifier>
</sbdh:Receiver>
<sbdh:DocumentIdentification>
<sbdh:Standard>EPCGlobal</sbdh:Standard>
<sbdh:TypeVersion>1.9</sbdh:TypeVersion>
<sbdh:InstanceIdentifier>urn:uuid:e3aa929f-3ba1-445d-9c4d-4beaeae362f7</sbdh:InstanceIdentifier>
<sbdh:Type>Events</sbdh:Type>
<sbdh:CreationDateAndTime>2919-95-17T16:48:53.428Z</sbdh:CreationDateAndTime>
</sbdh:DocumentIdentification>
</sbdh:StandardBusinessDocumentHeader>
</EPCISHeader>
<EPCISBody>
<EventList>
<ObjectEvent>
<eventTime>2919-95-99T14:55:21.123Z</eventTime>
<eventTimeZoneOffset>-95:99</eventTimeZoneOffset>
<epcList>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999676</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999675</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999673</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999677</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999699</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999694</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999692</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999698</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999697</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999696</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999695</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999679</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999678</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999683</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999682</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999681</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999689</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999685</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999684</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999792</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999791</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999689</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999799</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999688</epc>
</epcList>
<action>ADD</action>
<bizStep>urn:epcglobal:cbv:bizstep:commissioning</bizStep>
<disposition>urn:epcglobal:cbv:disp:active</disposition>
<readPoint>
<id>urn:epc:id:sgln:03555555.999.9</id>
</readPoint>
<bizLocation>
<id>urn:epc:id:sgln:03555555.999.9</id>
</bizLocation>
<gs1ushc:eventID>fa9a7db6-6be9-4a5c-bb91-b46631c45e28</gs1ushc:eventID>
<extension>
<ilmd>
<lotNumber>959922</lotNumber>
<itemExpirationDate>2919-96-39</itemExpirationDate>
</ilmd>
</extension>
</ObjectEvent>
<ObjectEvent>
<eventTime>2919-95-99T14:55:21.123Z</eventTime>
<eventTimeZoneOffset>-95:99</eventTimeZoneOffset>
<epcList>
<epc>urn:epc:id:sgtin:0355555.192169.19999999999219</epc>
</epcList>
<action>ADD</action>
<bizStep>urn:epcglobal:cbv:bizstep:commissioning</bizStep>
<disposition>urn:epcglobal:cbv:disp:active</disposition>
<readPoint>
<id>urn:epc:id:sgln:03555555.999.9</id>
</readPoint>
<bizLocation>
<id>urn:epc:id:sgln:03555555.999.9</id>
</bizLocation>
<gs1ushc:eventID>cbcc4112-754a-424a-8e9e-63756c435658</gs1ushc:eventID>
<extension>
<ilmd>
<lotNumber>959922</lotNumber>
<itemExpirationDate>2919-96-39</itemExpirationDate>
</ilmd>
</extension>
</ObjectEvent>
<ObjectEvent>
<eventTime>2919-95-99T14:55:21.123Z</eventTime>
<eventTimeZoneOffset>-95:99</eventTimeZoneOffset>
<epcList>
<epc>urn:epc:id:sscc:0355555.9999299233</epc>
</epcList>
<action>ADD</action>
<bizStep>urn:epcglobal:cbv:bizstep:commissioning</bizStep>
<disposition>urn:epcglobal:cbv:disp:active</disposition>
<readPoint>
<id>urn:epc:id:sgln:03555555.999.9</id>
</readPoint>
<bizLocation>
<id>urn:epc:id:sgln:03555555.999.9</id>
</bizLocation>
<gs1ushc:eventID>9827e383-2889-4ceb-ae52-a8bfcbe35a58</gs1ushc:eventID>
<extension>
<ilmd>
<lotNumber>959922</lotNumber>
<itemExpirationDate>2919-96-39</itemExpirationDate>
</ilmd>
</extension>
</ObjectEvent>
<AggregationEvent>
<eventTime>2919-95-99T14:55:21.123Z</eventTime>
<eventTimeZoneOffset>-95:99</eventTimeZoneOffset>
<parentID>urn:epc:id:sscc:0355555.9999299233</parentID>
<childEPCs>
<epc>urn:epc:id:sgtin:0355555.192169.19999999999219</epc>
</childEPCs>
<action>ADD</action>
<bizStep>urn:epcglobal:cbv:bizstep:packing</bizStep>
<disposition>urn:epcglobal:cbv:disp:in_progress</disposition>
<readPoint>
<id>urn:epc:id:sgln:03555555.999.9</id>
</readPoint>
<bizLocation>
<id>urn:epc:id:sgln:03555555.999.9</id>
</bizLocation>
<gs1ushc:eventID>bf98c31e-bd7f-43a5-aad7-c61747143c11</gs1ushc:eventID>
</AggregationEvent>
<AggregationEvent>
<eventTime>2919-95-99T14:55:21.123Z</eventTime>
<eventTimeZoneOffset>-95:99</eventTimeZoneOffset>
<parentID>urn:epc:id:sgtin:0355555.192169.19999999999219</parentID>
<childEPCs>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999676</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999675</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999673</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999677</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999699</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999694</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999692</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999698</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999697</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999696</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999695</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999679</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999678</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999683</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999682</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999681</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999689</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999685</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999684</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999792</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999791</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999689</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999799</epc>
<epc>urn:epc:id:sgtin:0355555.012345.19999999999688</epc>
</childEPCs>
<action>ADD</action>
<bizStep>urn:epcglobal:cbv:bizstep:packing</bizStep>
<disposition>urn:epcglobal:cbv:disp:in_progress</disposition>
<readPoint>
<id>urn:epc:id:sgln:03555555.999.9</id>
</readPoint>
<bizLocation>
<id>urn:epc:id:sgln:03555555.999.9</id>
</bizLocation>
<gs1ushc:eventID>64f3ff17-c524-4c63-8eae-2544be8e66c9</gs1ushc:eventID>
</AggregationEvent>
<ObjectEvent>
<eventTime>2919-95-17T16:98:25.469Z</eventTime>
<eventTimeZoneOffset>-95:99</eventTimeZoneOffset>
<epcList>
<epc>urn:epc:id:sscc:0355555.9999299233</epc>
</epcList>
<action>OBSERVE</action>
<bizStep>urn:epcglobal:cbv:bizstep:shipping</bizStep>
<disposition>urn:epcglobal:cbv:disp:in_transit</disposition>
<readPoint>
<id>urn:epc:id:sgln:03555555.999.9</id>
</readPoint>
<bizTransactionList>
<bizTransaction type="urn:epcglobal:cbv:btt:po">urn:epcglobal:cbv:bt:9815611924568:Test 1</bizTransaction>
<bizTransaction type="urn:epcglobal:cbv:btt:desadv">urn:epcglobal:cbv:bt:9815611924568:963842</bizTransaction>
</bizTransactionList>
<extension>
<sourceList>
<source type="urn:epcglobal:cbv:sdt:owning_party">urn:epc:id:sgln:03555555.456.8</source>
<source type="urn:epcglobal:cbv:sdt:location">urn:epc:id:sgln:03555555.999.9</source>
</sourceList>
<destinationList>
<destination type="urn:epcglobal:cbv:sdt:owning_party">urn:epc:id:sgln:0355555.99999.9</destination>
<destination type="urn:epcglobal:cbv:sdt:location">urn:epc:id:sgln:9996295.99493.9</destination>
</destinationList>
</extension>
<gs1ushc:eventID>fdc991b2-58c9-4bdc-b43c-6d6ddce3c8ae</gs1ushc:eventID>
</ObjectEvent>
</EventList>
</EPCISBody>
</epcis:EPCISDocument>
......@@ -55,6 +55,11 @@ class TestEparsecis(unittest.TestCase):
os.path.join(curpath, 'data/epcis.xml'))
parser.parse()
def test_no_cbv_namespace_file(self):
curpath = os.path.dirname(__file__)
parser = TestParser(
os.path.join(curpath, 'data/no-cbv-namespace.xml'))
parser.parse()
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment