Beispiel #1
0
def test_premium_payment_gateway():
    try:
        msg = process_payment(
            501.0,
            CreditCard('5500000000000004', 'dummy user', datetime(2022, 1,
                                                                  31)))
        assert isinstance(msg, str)
    except Exception as ex:
        assert isinstance(ex, PaymentGatewayUnavailable)
def test_invalid_credit_card_number():
    with pytest.raises(InvalidCreditCardNumber):
        CreditCard('000000000000', 'dummy name', datetime(2022, 1, 31))
def test_expired_credit_card():
    with pytest.raises(ExpiredCreditCard):
        CreditCard('5500000000000004', 'dummy name', datetime(2020, 1, 31))
def test_invalid_credit_card_security_code():
    with pytest.raises(InvalidCreditCardSecurityCode):
        CreditCard('5500000000000004', 'dummy name', datetime(2022, 1, 31),
                   '0000')
def test_invalid_credit_card_expiration_date():
    with pytest.raises(InvalidCreditCardExpirationDate):
        CreditCard('5500000000000004', 'dummy name', None)
def test_invalid_credit_card_holder():
    with pytest.raises(InvalidCreditCardHolder):
        CreditCard('5500000000000004', None, datetime(2022, 1, 31))
Beispiel #7
0
def test_invalid_amount():
    with pytest.raises(InvalidAmount):
        process_payment(
            0.0,
            CreditCard('5500000000000004', 'dummy user', datetime(2022, 1,
                                                                  31)))