def test_missing_CUC(): "The `debtor` entity must always have a CUC." payment = Payment(debtor=biz, account=acct_37) payment.add_transaction(amount=1, account=acct_86, creditor=biz, rmtinfo='Test') with pytest.raises(MissingCUCError): payment.xml()
def test_empty_payment(): "Payments without any transaction must raise an exception." with pytest.raises(NoTransactionsError): payment = Payment(debtor=biz_with_cuc, account=acct_86, abi='01101', envelope=False) payment.xml()
def test_payment_basic(): payment = Payment(debtor=biz_with_cuc, account=acct_37, req_id='StaticId', execution_date=date(2014, 5, 15)) payment.add_transaction(amount=198.25, account=acct_86, creditor=beta, rmtinfo='Causale 1') compare_xml(payment.xml_text(), 'payment_basic.xml')
def test_empty_payment(): "Payments without any transaction must raise an exception." with pytest.raises(NoTransactionsError): payment = Payment( debtor=biz_with_cuc, account=acct_86, abi='01101', envelope=False ) payment.xml()
def test_invalid_iban(): payment = Payment(debtor=biz_with_cuc, account='ITINVALIDIBAN') with pytest.raises(InvalidIBANError): payment.xml() payment.account = 'XXINVALIDIBAN' payment.abi = '01234' with pytest.raises(InvalidIBANError): payment.xml() payment.account = acct_37.replace('IT37', 'IT99') with pytest.raises(InvalidIBANError): payment.xml()
def test_missing_attr_transaction(): """ Transactions must always have `amount`, `account`, `rmtinfo`, `creditor`. """ basic_data = { 'amount': 1, 'account': acct_86, 'creditor': biz, } for params in gen_dictionaries_with_one_missing_item(basic_data): payment = Payment(debtor=biz_with_cuc, account=acct_37) params['rmtinfo'] = 'Test' with pytest.raises(AttributeError): payment.add_transaction(**params) payment.xml() payment = simple_payment() with pytest.raises(AssertionError): payment.add_transaction(**basic_data)
def test_wrong_address_format(): "Address must be a list or tuple of at most two lines." holder = IdHolder(name='Test Business S.P.A.', cf='12312312311', country='IT', address=['Xyz', 'Via Giuseppe Verdi, 15', '33100 Udine'], cuc='XYZZZZ') payment = Payment(debtor=holder, account=acct_37) payment.add_transaction(amount=1, account=acct_86, docs=(Invoice(1), ), creditor=alpha) with pytest.raises(AddressFormatError): payment.xml() holder.address = [ 'A single line which is too long to fit in the holder address ' 'field, which can hold at most 70 characters per line', 'test' ] with pytest.raises(AddressFormatError): payment.xml()
def test_wrong_address_format(): "Address must be a list or tuple of at most two lines." holder = IdHolder( name='Test Business S.P.A.', cf='12312312311', country='IT', address=['Xyz', 'Via Giuseppe Verdi, 15', '33100 Udine'], cuc='XYZZZZ') payment = Payment(debtor=holder, account=acct_37) payment.add_transaction(amount=1, account=acct_86, docs=(Invoice(1),), creditor=alpha) with pytest.raises(AddressFormatError): payment.xml() holder.address = [ 'A single line which is too long to fit in the holder address ' 'field, which can hold at most 70 characters per line', 'test' ] with pytest.raises(AddressFormatError): payment.xml()
def test_payment_basic(): payment = Payment(debtor=biz_with_sia, account=acct_37, req_id='StaticId', execution_date=date(2014, 5, 15)) payment.add_transaction(amount=198.25, account=acct_86, creditor=beta, rmtinfo='Causale 1') compare_cbi(payment.cbi_text(), 'payment_basic.txt')
def test_missing_attrs_payment(): "Payments must always have a `debtor` and an `account` attribute." payment = Payment() with pytest.raises(AttributeError): payment.xml() payment.debtor = biz_with_cuc with pytest.raises(AttributeError): payment.xml() payment.account = acct_37 # No exception must be raised payment.add_transaction(amount=1, account=acct_86, rmtinfo='Test', creditor=biz) payment.xml()
from sepacbi import IdHolder, Payment payer = IdHolder(name='Ethics S.r.l.', cf='02519740415', cuc='1408170V') payment = Payment(debtor=payer, account='IT22O0101003403100000006001') payment.add_transaction(creditor=IdHolder(name='Zanotti David'), account='IT21V020082430900004042591', amount=100.00, rmtinfo='Acconto compenso') payment.add_transaction(creditor=IdHolder(name='Ostigh Paolo'), account='IT32S0305155181000020460770', amount=100.00, rmtinfo='Acconto compenso') print payment.xml_text()
def simple_payment(): return Payment(debtor=biz_with_cuc, account=acct_37)
def test_payment_multitrans(): payment = Payment(debtor=biz_with_sia, account=acct_37, req_id='StaticId', execution_date=date(2014, 5, 15)) payment.add_transaction(amount=198.25, account=acct_86, creditor=beta, rmtinfo='Causale 1') payment.add_transaction(amount=350.00, account=acct_37, creditor=biz_with_sia, rmtinfo='Altra causale') payment.add_transaction(amount=9532.21, account=acct_86, bic='ABCDESNN', creditor=alpha, docs=[Invoice(18512, 4500), DebitNote(1048, 5032.21, date(1995, 4, 21))]) payment.add_transaction( amount=1242.80, creditor=pvt, account=acct_86, category='SALA', rmtinfo='Salary') compare_cbi(payment.cbi_text(), 'payment_multitrans.txt')
def test_missing_abi(): "If the debtor has a foreign account, the ABI must be supplied." payment = Payment(debtor=biz_with_cuc, account=foreign_acct) payment.add_transaction(amount=1, account=acct_86, rmtinfo='Test') with pytest.raises(MissingABIError): payment.xml()
def test_payment_misc_features(): payment = Payment( debtor=biz, account=acct_37, req_id='StaticId', execution_date=date(2014, 5, 15), ultimate_debtor=beta, charges_account=acct_86, envelope=True, initiator=biz_with_sia, batch=True, high_priority=True) payment.add_transaction(amount=198.25, account=acct_86, creditor=beta, rmtinfo='Causale 1') compare_cbi(payment.cbi_text(), 'payment_misc_1.txt') payment.high_priority = False payment.add_transaction(amount=350.00, account=acct_37, creditor=biz_with_cuc, rmtinfo='Altra causale') payment.add_transaction(amount=9532.21, account=acct_86, bic='ABCDESNN', creditor=alpha, docs=[Invoice(18512, 4500, date(2009, 7, 17)), DebitNote(1048, 5032.21, date(1995, 4, 21))]) payment.add_transaction( amount=1242.80, creditor=pvt, account=acct_86, category='SALA', docs=[Text('Salary payment')]) compare_cbi(payment.cbi_text(), 'payment_misc_2.txt')