From: Henryk Plötz Date: Mon, 10 Sep 2018 20:38:16 +0000 (+0200) Subject: Add test for get_transactions and for fetching with touchdowns X-Git-Tag: v2.0.0~1^2~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff8e6825169e2337d4a6ebdd2a254c59e20e8156;p=thirdparty%2Fpython-fints.git Add test for get_transactions and for fetching with touchdowns --- diff --git a/tests/conftest.py b/tests/conftest.py index 59fc30d..6c1bb7b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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') diff --git a/tests/test_client.py b/tests/test_client.py index e61b5d2..f2cb794 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -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')