# encoding: utf-8 import datetime import pytest from sepaxml import SepaTransfer from tests.utils import clean_ids, validate_xml @pytest.fixture def strf_eur(): return SepaTransfer({ "name": "Miller & Son Ltd", "IBAN": "NL50BANK1234567890", "BIC": "BANKNL2A", "batch": True, "currency": "EUR" }, schema="pain.001.001.03") SAMPLE_RESULT = b""" 20180724041136-3b840ce62087 2018-07-24T16:11:36 1 10.12 Miller & Son Ltd MillerSonLtd-67c22f433a9e TRF true 1 10.12 SEPA 2018-07-24 Miller & Son Ltd NL50BANK1234567890 BANKNL2A SLEV test123 10.12 BANKNL2A This is a test NL50BANK1234567890 Test transaction """ def test_payment_overrides_currency(strf_eur): """Test that payment currency overrides config currency""" payment = { "name": "This is a test", "IBAN": "NL50BANK1234567890", "BIC": "BANKNL2A", "amount": 1012, "execution_date": datetime.date.today(), "description": "Test transaction", "endtoend_id": "test123", "currency": "GBP" # Override the EUR config currency } strf_eur.add_payment(payment) xmlout = strf_eur.export() xmlpretty = validate_xml(xmlout, "pain.001.001.03") assert clean_ids(xmlpretty.strip()) == clean_ids(SAMPLE_RESULT.strip())