gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin-tests] branch master updated: Add new sample and compare JSONs


From: gnunet
Subject: [libeufin-tests] branch master updated: Add new sample and compare JSONs.
Date: Tue, 24 Nov 2020 19:17:46 +0100

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin-tests.

The following commit(s) were added to refs/heads/master by this push:
     new 828eae6  Add new sample and compare JSONs.
828eae6 is described below

commit 828eae6dc91972b88339bc7ea6ce81912b085ddc
Author: MS <ms@taler.net>
AuthorDate: Tue Nov 24 19:14:40 2020 +0100

    Add new sample and compare JSONs.
---
 checks.py                             |  36 ++++++++--
 samples/camt53_example2.xml           | 131 ++++++++++++++++++++++++++++++++++
 samples/camt53_example2_expected.json |  45 ++++++++++++
 3 files changed, 206 insertions(+), 6 deletions(-)

diff --git a/checks.py b/checks.py
index 16524f6..1cd4c6f 100755
--- a/checks.py
+++ b/checks.py
@@ -2,18 +2,42 @@
 
 import os
 import sys
-from subprocess import check_call
+import json
+from deepdiff import DeepDiff
+from subprocess import Popen, PIPE
 
 if not os.path.isfile("./libeufin/gradlew"):
     print("libeufin submodule is missing.  Run bootstrap first?")
     sys.exit(1)
 
+# return dict with parse-result.
 def call_parser(xml_file):
     assert os.path.isfile(xml_file)
     xml_file_abs = os.path.abspath(xml_file)
-    check_call([
-        "./libeufin/gradlew", "-p",  "./libeufin", "nexus:run", 
f"--args=parse-camt {xml_file_abs}"
-    ])
+    with Popen([
+        "./libeufin/gradlew",
+        "--console=plain",
+        "-q",
+        "-p",
+        "./libeufin",
+        "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 test_camt53_example1():
-    call_parser("./samples/camt53_example1.xml")
+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_example2():
+    parsed = call_parser("./samples/camt53_example2.xml")
+    expected = get_json_from_disk("./samples/camt53_example2_expected.json")
+    assert_json_equal(parsed, expected)
diff --git a/samples/camt53_example2.xml b/samples/camt53_example2.xml
new file mode 100644
index 0000000..9eb94fb
--- /dev/null
+++ b/samples/camt53_example2.xml
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.04" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:camt.053.001.04 
camt.053.001.04.xsd">
+  <BkToCstmrStmt>
+    <GrpHdr>
+      <MsgId>C053201124181701</MsgId>
+      <CreDtTm>2020-11-24T18:17:26+01:00</CreDtTm>
+      <MsgRcpt>
+        <Id>
+          <OrgId>
+            <AnyBIC>UBSWCHZHCCS</AnyBIC>
+          </OrgId>
+        </Id>
+      </MsgRcpt>
+      <MsgPgntn>
+        <PgNb>1</PgNb>
+        <LastPgInd>true</LastPgInd>
+      </MsgPgntn>
+      <AddtlInf>SPS/1.7</AddtlInf>
+    </GrpHdr>
+    <Stmt>
+      <Id>0002011241817001</Id>
+      <ElctrncSeqNb>1</ElctrncSeqNb>
+      <CreDtTm>2020-11-24T18:17:26+01:00</CreDtTm>
+      <FrToDt>
+        <FrDtTm>2020-11-24T00:00:00+01:00</FrDtTm>
+        <ToDtTm>2020-11-24T24:00:00+01:00</ToDtTm>
+      </FrToDt>
+      <Acct>
+        <Id>
+          <IBAN>CH2801234000123456789</IBAN>
+        </Id>
+        <Ccy>CHF</Ccy>
+        <Ownr>
+          <Nm>UNIFITS GmbH</Nm>
+        </Ownr>
+        <Svcr>
+          <FinInstnId>
+            <BICFI>UBSWCHZH80A</BICFI>
+            <Nm>UBS SWITZERLAND AG</Nm>
+            <Othr>
+              <Id>CHE-116.303.292 MWST</Id>
+              <Issr>VAT-ID</Issr>
+            </Othr>
+          </FinInstnId>
+        </Svcr>
+      </Acct>
+      <Bal>
+        <Tp>
+          <CdOrPrtry>
+            <Cd>OPBD</Cd>
+          </CdOrPrtry>
+        </Tp>
+        <Amt Ccy="CHF">10000</Amt>
+        <CdtDbtInd>CRDT</CdtDbtInd>
+        <Dt>
+          <Dt>2020-11-24</Dt>
+        </Dt>
+      </Bal>
+      <Bal>
+        <Tp>
+          <CdOrPrtry>
+            <Cd>CLBD</Cd>
+          </CdOrPrtry>
+        </Tp>
+        <Amt Ccy="CHF">9975.7</Amt>
+        <CdtDbtInd>CRDT</CdtDbtInd>
+        <Dt>
+          <Dt>2020-11-24</Dt>
+        </Dt>
+      </Bal>
+      <Bal>
+        <Tp>
+          <CdOrPrtry>
+            <Cd>CLAV</Cd>
+          </CdOrPrtry>
+        </Tp>
+        <Amt Ccy="CHF">9975.7</Amt>
+        <CdtDbtInd>CRDT</CdtDbtInd>
+        <Dt>
+          <Dt>2020-11-24</Dt>
+        </Dt>
+      </Bal>
+      <Ntry>
+        <Amt Ccy="CHF">24.3</Amt>
+        <CdtDbtInd>DBIT</CdtDbtInd>
+        <Sts>BOOK</Sts>
+        <BookgDt>
+          <Dt>2020-11-24</Dt>
+        </BookgDt>
+        <ValDt>
+          <Dt>2020-11-24</Dt>
+        </ValDt>
+        <AcctSvcrRef>ACSR201124181701</AcctSvcrRef>
+        <BkTxCd>
+          <Domn>
+            <Cd>PMNT</Cd>
+            <Fmly>
+              <Cd>ICDT</Cd>
+              <SubFmlyCd>DMCT</SubFmlyCd>
+            </Fmly>
+          </Domn>
+          <Prtry>
+            <Cd>Z24</Cd>
+          </Prtry>
+        </BkTxCd>
+        <AddtlInfInd>
+          <MsgNmId>camt.054.001.04</MsgNmId>
+          <MsgId>C054201124181701</MsgId>
+        </AddtlInfInd>
+        <AmtDtls>
+          <InstdAmt>
+            <Amt Ccy="CHF">24.3</Amt>
+          </InstdAmt>
+          <TxAmt>
+            <Amt Ccy="CHF">24.3</Amt>
+          </TxAmt>
+        </AmtDtls>
+        <NtryDtls>
+          <Btch>
+            <MsgId>UXC20112400010</MsgId>
+            <PmtInfId>UXC20112400010PI00001</PmtInfId>
+            <NbOfTxs>2</NbOfTxs>
+            <TtlAmt Ccy="CHF">24.3</TtlAmt>
+            <CdtDbtInd>DBIT</CdtDbtInd>
+          </Btch>
+        </NtryDtls>
+        <AddtlNtryInf>Order</AddtlNtryInf>
+      </Ntry>
+    </Stmt>
+  </BkToCstmrStmt>
+</Document>
\ No newline at end of file
diff --git a/samples/camt53_example2_expected.json 
b/samples/camt53_example2_expected.json
new file mode 100644
index 0000000..d604684
--- /dev/null
+++ b/samples/camt53_example2_expected.json
@@ -0,0 +1,45 @@
+{
+  "messageType" : "statement",
+  "messageId" : "C053201124181701",
+  "creationDateTime" : "2020-11-24T18:17:26+01:00",
+  "reports" : [ {
+    "id" : "0002011241817001",
+    "creationDateTime" : "2020-11-24T18:17:26+01:00",
+    "electronicSequenceNumber" : 1,
+    "fromDate" : "2020-11-24T00:00:00+01:00",
+    "toDate" : "2020-11-24T24:00:00+01:00",
+    "account" : {
+      "currency" : "CHF",
+      "iban" : "CH2801234000123456789"
+    },
+    "balances" : [ {
+      "type" : "OPBD",
+      "date" : "2020-11-24",
+      "creditDebitIndicator" : "CRDT",
+      "amount" : "CHF:10000"
+    }, {
+      "type" : "CLBD",
+      "date" : "2020-11-24",
+      "creditDebitIndicator" : "CRDT",
+      "amount" : "CHF:9975.7"
+    }, {
+      "type" : "CLAV",
+      "date" : "2020-11-24",
+      "creditDebitIndicator" : "CRDT",
+      "amount" : "CHF:9975.7"
+    } ],
+    "entries" : [ {
+      "amount" : "CHF:24.3",
+      "creditDebitIndicator" : "DBIT",
+      "status" : "BOOK",
+      "bankTransactionCode" : "PMNT-ICDT-DMCT",
+      "valueDate" : "2020-11-24",
+      "bookingDate" : "2020-11-24",
+      "accountServicerRef" : "ACSR201124181701",
+      "instructedAmount" : "CHF:24.3",
+      "batches" : [ {
+        "batchTransactions" : [ ]
+      } ]
+    } ]
+  } ]
+}

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]