diff --git a/mhs/common/mhs_common/messages/ebxml_envelope.py b/mhs/common/mhs_common/messages/ebxml_envelope.py index bdbe46af..c1c3e8d6 100644 --- a/mhs/common/mhs_common/messages/ebxml_envelope.py +++ b/mhs/common/mhs_common/messages/ebxml_envelope.py @@ -230,12 +230,12 @@ def parse_external_attachments(xml_tree: Element) -> Dict[str, str]: description_variables = dict(pair.split("=", 1) for pair in variables) if "Filename" in description_variables: filename = description_variables["Filename"].replace('\\', '') - + mid = mid_attribute.split(":")[1] - external_attachment = { + external_attachment = { EXTERNAL_ATTACHMENT_DOCUMENT_ID :document_id_attribute, EXTERNAL_ATTACHMENT_MESSAGE_ID :mid_attribute.split(":")[1], - EXTERNAL_ATTACHMENT_DESCRIPTION: description, + EXTERNAL_ATTACHMENT_DESCRIPTION: description, EXTERNAL_ATTACHMENT_TITLE: filename } diff --git a/mhs/common/mhs_common/messages/tests/test_ebxml_envelope.py b/mhs/common/mhs_common/messages/tests/test_ebxml_envelope.py index ed3ae378..1d5ac671 100644 --- a/mhs/common/mhs_common/messages/tests/test_ebxml_envelope.py +++ b/mhs/common/mhs_common/messages/tests/test_ebxml_envelope.py @@ -46,17 +46,13 @@ def test_cant_find_optional_text_value_during_parsing(self): self.assertEqual({}, values_dict) def test_filename_contains_equals_sign(self): - expected_external_attachment1 = { - 'document_id': 'EB653254-7854-450E-A3D3-B1711D99D665_adrian=marbles.BMP', - 'message_id': 'MESSAGE GOES HERE', - 'description': 'DESCRIPTION GOES HERE', - 'title': 'EB653254-7854-450E-A3D3-B1711D99D665_adrian=marbles.BMP' - }, - expected_external_attachment2 = { + expected_external_attachment = { 'document_id': '_735BB673-D9C0-4B85-951E-98DD045C4713', 'message_id': 'E54DEC57-6BA5-40AB-ACD0-1E383209C034', - 'description': 'DESCRIPTION GOES HERE', - 'title': 'EB653254-7854-450E-A3D3-B1711D99D665_adrian=marbles.BMP' + 'description': 'Filename="735BB673-D9C0-4B85-951E-98DD045C4713_adrian=marbles2.BMP" ' + 'ContentType=application/octet-stream Compressed=Yes LargeAttachment=NoOriginalBase64=No ' + 'Length=3345444', + 'title': '"735BB673-D9C0-4B85-951E-98DD045C4713_adrian=marbles2.BMP"' } message = file_utilities.get_file_string( @@ -65,5 +61,12 @@ def test_filename_contains_equals_sign(self): xml_tree = ElementTree.fromstring(message) external_attachments = ebxml_envelope.EbxmlEnvelope.parse_external_attachments(xml_tree)['external_attachments'] - self.assertEqual(external_attachments[0], expected_external_attachment1) + + print("\n DEBUG external_attachments \n") + print(external_attachments) + print("\n DEBUG expected_external_attachment \n") + print(expected_external_attachment) + print("\n") + + self.assertEqual(external_attachments[0], expected_external_attachment) diff --git a/mhs/common/mhs_common/messages/tests/test_messages/ebxml_request_manifest_contains_filename_with_equals.xml b/mhs/common/mhs_common/messages/tests/test_messages/ebxml_request_manifest_contains_filename_with_equals.xml index a06052ae..f19906d8 100644 --- a/mhs/common/mhs_common/messages/tests/test_messages/ebxml_request_manifest_contains_filename_with_equals.xml +++ b/mhs/common/mhs_common/messages/tests/test_messages/ebxml_request_manifest_contains_filename_with_equals.xml @@ -30,19 +30,12 @@ RCMR_IN030000UK07 - - Filename="EB653254-7854-450E-A3D3-B1711D99D665_adrian=marbles.BMP" - ContentType=application/octet-stream Compressed=Yes LargeAttachment=No - OriginalBase64=No Length=3345444 - - Filename="735BB673-D9C0-4B85-951E-98DD045C4713_adrian=marbles2.BMP" - ContentType=application/octet-stream Compressed=Yes LargeAttachment=No - OriginalBase64=No Length=3345444 + + Filename="735BB673-D9C0-4B85-951E-98DD045C4713_adrian=marbles2.BMP" ContentType=application/octet-stream Compressed=Yes LargeAttachment=No OriginalBase64=No Length=3345444 +