# encoding: utf-8 import datetime import pytest from sepaxml import SepaDD from tests.utils import clean_ids, validate_xml @pytest.fixture def sdd(): return SepaDD({ "name": "Miller & Son Ltd", "IBAN": "NL50BANK1234567890", "BIC": "BANKNL2A", "batch": True, "creditor_id": "DE26ZZZ00000000000", "currency": "EUR" }, schema="pain.008.001.02") SAMPLE_RESULT = b""" 20012017014921-ba2dab283fdd 2017-01-20T13:49:21 2 60.12 Miller & Son Ltd DE26ZZZ00000000000 MillerSonLtd-ecd6a2f680ce DD true 1 10.12 SEPA CORE FRST 2017-01-20 Miller & Son Ltd NL50BANK1234567890 BANKNL2A SLEV DE26ZZZ00000000000 SEPA ebd75e7e649375d91b33dc11ae44c0e1 10.12 1234 2017-01-20 BANKNL2A Test & Co. NL50BANK1234567890 Test transaction1 MillerSonLtd-d547a1b3882f DD true 1 50.00 SEPA CORE RCUR 2017-01-20 Miller & Son Ltd NL50BANK1234567890 BANKNL2A SLEV DE26ZZZ00000000000 SEPA af755a40cb692551ed9f9d55f7179525 50.00 1234 2017-01-20 BANKNL2A Test du Test NL50BANK1234567890 Testgrusse <html> """ def test_two_debits(sdd): payment1 = { "name": "Test & Co.", "IBAN": "NL50BANK1234567890", "BIC": "BANKNL2A", "amount": 1012, "type": "FRST", "collection_date": datetime.date.today(), "mandate_id": "1234", "mandate_date": datetime.date.today(), "description": "Test transaction1", "endtoend_id": "ebd75e7e649375d91b33dc11ae44c0e1" } payment2 = { "name": "Test du Test", "IBAN": "NL50BANK1234567890", "BIC": "BANKNL2A", "amount": 5000, "type": "RCUR", "collection_date": datetime.date.today(), "mandate_id": "1234", "mandate_date": datetime.date.today(), "description": u"Testgrüße ", "endtoend_id": "af755a40cb692551ed9f9d55f7179525" } sdd.add_payment(payment1) sdd.add_payment(payment2) xmlout = sdd.export() xmlpretty = validate_xml(xmlout, "pain.008.001.02") assert clean_ids(xmlpretty.strip()) == clean_ids(SAMPLE_RESULT.strip())