summaryrefslogtreecommitdiff
path: root/parsing-tests
diff options
context:
space:
mode:
authorMS <ms@taler.net>2020-12-08 09:46:47 +0100
committerMS <ms@taler.net>2020-12-08 09:46:47 +0100
commitaeeb5b5f2b4a32ec825da0ff8d9e6c9bdb1dc2c8 (patch)
treecde5bf08574fc01ac7c7d6e43e73033e82c6c183 /parsing-tests
parentc4601d928e588a7639610cbc37b5e741990ca8ca (diff)
downloadlibeufin-aeeb5b5f2b4a32ec825da0ff8d9e6c9bdb1dc2c8.tar.gz
libeufin-aeeb5b5f2b4a32ec825da0ff8d9e6c9bdb1dc2c8.tar.bz2
libeufin-aeeb5b5f2b4a32ec825da0ff8d9e6c9bdb1dc2c8.zip
Parsing tests.
Importing here the tests runner, and keep only the samples in a separate repository.
Diffstat (limited to 'parsing-tests')
-rwxr-xr-xparsing-tests/checks.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/parsing-tests/checks.py b/parsing-tests/checks.py
new file mode 100755
index 00000000..68308137
--- /dev/null
+++ b/parsing-tests/checks.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+import json
+from deepdiff import DeepDiff
+from subprocess import Popen, PIPE
+
+# return dict with parse-result.
+def call_parser(xml_file):
+ assert os.path.isfile(xml_file)
+ xml_file_abs = os.path.abspath(xml_file)
+ with Popen([
+ "../gradlew",
+ "--console=plain",
+ "-q",
+ "-p",
+ "..",
+ "nexus:run",
+ f"--args=parse-camt {xml_file_abs}"],
+ stdout=PIPE
+ ) as proc:
+ stdout = proc.communicate()[0]
+ assert proc.returncode == 0
+ return json.loads(stdout)
+
+def get_json_from_disk(json_file):
+ json_file_abs = os.path.abspath(json_file)
+ with open(json_file_abs) as j:
+ return json.load(j)
+
+def assert_json_equal(json1, json2):
+ diff = DeepDiff(json1, json2, ignore_order=True, report_repetition=True)
+ assert len(diff.keys()) == 0
+
+def test_camt53_example3():
+ parsed = call_parser("./samples/camt53_example3.xml")
+ entries = parsed["reports"][0]["entries"]
+ # The following checks ensure that each money movement is a singleton.
+ assert(len(entries) == 4)
+ assert(len(entries[0]["batches"][0]["batchTransactions"]) == 1)
+ assert(len(entries[1]["batches"][0]["batchTransactions"]) == 1)
+ assert(len(entries[2]["batches"][0]["batchTransactions"]) == 1)
+ assert(len(entries[3]["batches"][0]["batchTransactions"]) == 1)