Example #1
0
def test_expired_credit_card():
    """test if a credit card number is expired"""
    credit_card = CreditCard(number="4111111111111111",
                             exp_mo=LAST_YEAR.strftime('%m'),
                             exp_yr=LAST_YEAR.strftime('%Y'),
                             first_name="John",
                             last_name="Doe",
                             cvv="123",
                             strict=False)

    # safe check for luhn valid
    assert_false(credit_card.is_valid())

    # checking if the exception fires
    credit_card.validate()
Example #2
0
def test_invalid_cvv():
    """test if a credit card number has an invalid cvv"""
    credit_card = CreditCard(
        number="4111111111111111",
        exp_mo=NEXT_YEAR.strftime('%m'),
        exp_yr=NEXT_YEAR.strftime('%Y'),
        first_name="John",
        last_name="Doe",
        cvv="1",  # invalid cvv
        strict=True)

    # safe check for luhn valid
    assert_false(credit_card.is_valid())

    # checking if the exception fires
    credit_card.validate()
Example #3
0
def test_invalid():
    """test if a credit card number is luhn invalid"""
    credit_card = CreditCard(
            number = "4111111111111113", # invalid credit card
            exp_mo = "12",
            exp_yr = "2019",
            first_name = "John",
            last_name = "Doe",
            cvv = "123",
            strict = False
    )

    # checking if the exception fires
    credit_card.validate()

    # safe check for luhn valid
    assert_false(credit_card.is_valid())
Example #4
0
def test_invalid_cvv():
    """test if a credit card number has an invalid cvv"""
    credit_card = CreditCard(
            number = "4111111111111111",
            exp_mo = NEXT_YEAR.strftime('%m'),
            exp_yr = NEXT_YEAR.strftime('%Y'),
            first_name = "John",
            last_name = "Doe",
            cvv = "1", # invalid cvv
            strict = True
    )

    # safe check for luhn valid
    assert_false(credit_card.is_valid())

    # checking if the exception fires
    credit_card.validate()
Example #5
0
def test_expired_credit_card():
    """test if a credit card number is expired"""
    credit_card = CreditCard(
            number = "4111111111111111",
            exp_mo = LAST_YEAR.strftime('%m'),
            exp_yr = LAST_YEAR.strftime('%Y'),
            first_name = "John",
            last_name = "Doe",
            cvv = "123",
            strict = False
    )

    # safe check for luhn valid
    assert_false(credit_card.is_valid())

    # checking if the exception fires
    credit_card.validate()