]> git.ipfire.org Git - thirdparty/python-fints.git/commitdiff
Add test for get_transactions and for fetching with touchdowns
authorHenryk Plötz <henryk@ploetzli.ch>
Mon, 10 Sep 2018 20:38:16 +0000 (22:38 +0200)
committerRaphael Michel <mail@raphaelmichel.de>
Mon, 3 Dec 2018 18:34:29 +0000 (19:34 +0100)
tests/conftest.py
tests/test_client.py

index 59fc30db16e4cf8c30f928bb7c5e858c013e407d..6c1bb7b2d1efbd080a953b42ba63bb6e703abe8c 100644 (file)
@@ -79,6 +79,56 @@ def fints_server():
             if b"'HKSPA:" in message:
                 result.append(b"HISPA::1:4+J:DE111234567800000001:GENODE00TES:00001::280:1234567890'")
 
+            hkkaz = re.search(rb"'HKKAZ:(\d+):7\+[^+]+\+N(?:\+[^+]*\+[^+]*\+[^+]*\+([^+]*))?'", message)
+            if hkkaz:
+                if hkkaz.group(2):
+                    startat = int(hkkaz.group(2).decode('us-ascii'), 10)
+                else:
+                    startat = 0
+
+                transactions = [
+                    [
+                        b'-',
+                        b':20:STARTUMS',
+                        b':25:12345678/0000000001',
+                        b':28C:0',
+                        b':60F:C150101EUR1041,23',
+                        b':61:150101C182,34NMSCNONREF',
+                        b':86:051?00UEBERWEISG?10931?20Ihre Kontonummer 0000001234',
+                        b'?21/Test Ueberweisung 1?22n WS EREF: 1100011011 IBAN:',
+                        b'?23 DE1100000100000001234 BIC?24: GENODE11 ?1011010100',
+                        b'?31?32Bank',
+                        b':62F:C150101EUR1223,57',
+                        b'-',
+                    ], [
+                        b'-',
+                        b':20:STARTUMS',
+                        b':25:12345678/0000000001',
+                        b':28C:0',
+                        b':60F:C150301EUR1223,57',
+                        b':61:150301C100,03NMSCNONREF',
+                        b':86:051?00UEBERWEISG?10931?20Ihre Kontonummer 0000001234',
+                        b'?21/Test Ueberweisung 2?22n WS EREF: 1100011011 IBAN:',
+                        b'?23 DE1100000100000001234 BIC?24: GENODE11 ?1011010100',
+                        b'?31?32Bank',
+                        b':61:150301C100,00NMSCNONREF',
+                        b':86:051?00UEBERWEISG?10931?20Ihre Kontonummer 0000001234',
+                        b'?21/Test Ueberweisung 3?22n WS EREF: 1100011011 IBAN:',
+                        b'?23 DE1100000100000001234 BIC?24: GENODE11 ?1011010100',
+                        b'?31?32Bank',
+                        b':62F:C150101EUR1423,60',
+                        b'-',
+                    ]
+                ]
+
+                if startat+1 < len(transactions):
+                    result.append("HIRMS::2:{}+3040::Es liegen weitere Informationen vor: {}'".format(hkkaz.group(1).decode('us-ascii'), startat+1).encode('iso-8859-1'))
+
+                tx = b"\r\n".join([b''] + transactions[startat] + [b''])
+
+                result.append("HIKAZ::7:{}+@{}@".format(hkkaz.group(1).decode('us-ascii'), len(tx)).encode('us-ascii') + tx + b"'")
+
+
             hkccs = re.search(rb"'HKCCS:(\d+):1.*@\d+@(.*)/Document>'", message)
             if hkccs:
                 segno = hkccs.group(1).decode('us-ascii')
index e61b5d22bbcd376e36d75aea43fce7999d3a4fad..f2cb79475935133f9864ace64cb1806ea8ece44d 100644 (file)
@@ -181,3 +181,12 @@ def test_tan_hhduc(fints_client):
 
         b = fints_client.send_tan(a, flicker.startcode.data)
         assert b.status == ResponseStatus.SUCCESS
+
+def test_get_transactions(fints_client):
+    with fints_client:
+        accounts = fints_client.get_sepa_accounts()
+
+        transactions = fints_client.get_transactions(accounts[0])
+
+        assert len(transactions) == 3
+        assert transactions[0].data['amount'].amount == Decimal('182.34')