From dcd957fb6944ec6a5ec54ffcc2142e63afd05ad0 Mon Sep 17 00:00:00 2001 From: Pete Houghton Date: Mon, 23 Sep 2024 11:03:32 +0000 Subject: [PATCH] Added remt parse test --- example_files/remt/remt_001_001_06.xml | 90 ++++++++++++++++++++++++++ setup.py | 2 +- tests/parse_remt_msgs_test.py | 19 ++++++ 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 example_files/remt/remt_001_001_06.xml create mode 100644 tests/parse_remt_msgs_test.py diff --git a/example_files/remt/remt_001_001_06.xml b/example_files/remt/remt_001_001_06.xml new file mode 100644 index 0000000..3b0b6e4 --- /dev/null +++ b/example_files/remt/remt_001_001_06.xml @@ -0,0 +1,90 @@ + + + + + 20241001Ex1234 + 2024-10-01T09:00:00 + + + + + 623456 + + Exchange Framework + + + + + + + + + + 654326 + + Exchange Framework + + + + + + + + 20240427_121000322_1754_321 + + + + + CINV + + + 684528 + 2022-06-10 + + + + 3916.11 + + + + + + + + CINV + + + 683529 + 2022-06-10 + + + + 3916.99 + + + + + + Linking ID Example 1 + + + + ARC + + + + 7845.61 + + +
2022-07-10
+
+ + Payer McTest1 + + + Payee McTest1 + +
+
+
+
\ No newline at end of file diff --git a/setup.py b/setup.py index f33d229..005abab 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="pyiso20022", - version="1.4.4", + version="1.4.5", author="Peter Houghton", author_email="pete@investigatingsoftware.co.uk", description="pyiso20022 is a library for generating ISO20022 messages in Python.", diff --git a/tests/parse_remt_msgs_test.py b/tests/parse_remt_msgs_test.py new file mode 100644 index 0000000..9116ed2 --- /dev/null +++ b/tests/parse_remt_msgs_test.py @@ -0,0 +1,19 @@ +import pytest +from xsdata.formats.dataclass.parsers import XmlParser +from pyiso20022.remt.remt_001_001_06 import * +from decimal import Decimal + + +@pytest.mark.parametrize("expected_RmtAmtAndTp", [ + ("3916.11") + ]) +def test_parse_remt001_001_006(expected_RmtAmtAndTp): + + parser = XmlParser() + + with open("example_files/remt/remt_001_001_06.xml", "rb") as xml_file: + doc: Document = parser.parse(xml_file, Document, ) + + amount = doc.rmt_advc.rmt_inf[0].strd[0].rfrd_doc_amt.rmt_amt_and_tp[0].amt.value + + assert amount == Decimal(expected_RmtAmtAndTp)