예제 #1
0
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()
예제 #2
0
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()
예제 #3
0
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()
예제 #4
0
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()
예제 #5
0
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()
예제 #6
0
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)
예제 #7
0
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)
예제 #8
0
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()
예제 #9
0
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()
예제 #10
0
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()
예제 #11
0
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()
예제 #12
0
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()
예제 #13
0
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()
예제 #14
0
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()