# 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 1 10.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 MillerSonLtd-1234567890ab 10.12 1234 2017-01-20 BANKNL2A This is a test NL50BANK1234567890 Test transaction """ def test_payment_overrides_currency(sdd): """Test that payment currency overrides config currency""" payment = { "name": "This is a test", "IBAN": "NL50BANK1234567890", "BIC": "BANKNL2A", "amount": 1012, "type": "FRST", "collection_date": datetime.date.today(), "mandate_id": "1234", "mandate_date": datetime.date.today(), "description": "Test transaction", "currency": "GBP" # Override the EUR config currency } sdd.add_payment(payment) xmlout = sdd.export() xmlpretty = validate_xml(xmlout, "pain.008.001.02") assert clean_ids(xmlpretty.strip()) == clean_ids(SAMPLE_RESULT.strip())