Exemple #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()
Exemple #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()
Exemple #3
0
def test_full_name():
    """testing full_name support"""
    credit_card = CreditCard(number='4111111111111111',
                             exp_mo=NEXT_YEAR.strftime('%m'),
                             exp_yr=NEXT_YEAR.strftime('%Y'),
                             full_name='John Doe',
                             cvv='911',
                             strict=False)

    # safe check
    assert_true(credit_card.is_valid())

    # checking if our str() method (or repr()) is ok
    final_str = '<CreditCard -- John Doe, visa, ************1111, expires: %s/%s>' % (
        NEXT_YEAR.strftime('%m'), NEXT_YEAR.strftime('%Y'))
    assert_equals(str(credit_card), final_str)
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())
Exemple #5
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()
Exemple #6
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()
Exemple #7
0
def test_full_name():
    """testing full_name support"""
    credit_card = CreditCard(
            number = '4111111111111111',
            exp_mo = NEXT_YEAR.strftime('%m'),
            exp_yr = NEXT_YEAR.strftime('%Y'),
            full_name = 'John Doe',
            cvv = '911',
            strict = False
    )

    # safe check
    assert_true(credit_card.is_valid())

    # checking if our str() method (or repr()) is ok
    final_str = '<CreditCard -- John Doe, visa, ************1111, expires: %s/%s>' % (NEXT_YEAR.strftime('%m'), NEXT_YEAR.strftime('%Y'))
    assert_equals(str(credit_card), final_str)
def test_full_name():
    """testing full_name support"""
    credit_card = CreditCard(
            number = '4111111111111111',
            exp_mo = '02',
            exp_yr = '2012',
            full_name = 'John Doe',
            cvv = '911',
            strict = False
    )

    # safe check
    assert_true(credit_card.is_valid())

    # checking if our str() method (or repr()) is ok
    final_str = '<CreditCard -- John Doe, visa, ************1111, expires: 02/2012>'
    assert_equals(str(credit_card), final_str)
Exemple #9
0
def test_to_string():
    """test if a credit card outputs the right to str value"""
    credit_card = CreditCard(number='4111111111111111',
                             exp_mo=NEXT_YEAR.strftime('%m'),
                             exp_yr=NEXT_YEAR.strftime('%Y'),
                             first_name='John',
                             last_name='Doe',
                             cvv='911',
                             strict=False)

    # safe check
    assert_true(credit_card.is_valid())

    # checking if our str() method (or repr()) is ok
    final_str = '<CreditCard -- John Doe, visa, ************1111, expires: %s/%s>' % (
        NEXT_YEAR.strftime('%m'), NEXT_YEAR.strftime('%Y'))
    assert_equals(str(credit_card), final_str)
Exemple #10
0
def test_to_string():
    """test if a credit card outputs the right to str value"""
    credit_card = CreditCard(
            number = '4111111111111111',
            exp_mo = NEXT_YEAR.strftime('%m'),
            exp_yr = NEXT_YEAR.strftime('%Y'),
            first_name = 'John',
            last_name = 'Doe',
            cvv = '911',
            strict = False
    )

    # safe check
    assert_true(credit_card.is_valid())

    # checking if our str() method (or repr()) is ok
    final_str = '<CreditCard -- John Doe, visa, ************1111, expires: %s/%s>' % (NEXT_YEAR.strftime('%m'), NEXT_YEAR.strftime('%Y'))
    assert_equals(str(credit_card), final_str)
def test_to_string():
    """test if a credit card outputs the right to str value"""
    credit_card = CreditCard(
            number = '4111111111111111',
            exp_mo = '02',
            exp_yr = '2012',
            first_name = 'John',
            last_name = 'Doe',
            cvv = '911',
            strict = False
    )

    # safe check
    assert_true(credit_card.is_valid())

    # checking if our str() method (or repr()) is ok
    final_str = '<CreditCard -- John Doe, visa, ************1111, expires: 02/2012>'
    assert_equals(str(credit_card), final_str)
Exemple #12
0
def test_valid():
    """test if a credit card number is luhn valid"""
    for test_cc_type, test_cc_num in TEST_CARDS.items():
        # create a credit card object
        credit_card = CreditCard(
            number=test_cc_num,  # valid credit card
            exp_mo=NEXT_YEAR.strftime('%m'),
            exp_yr=NEXT_YEAR.strftime('%Y'),
            first_name="John",
            last_name="Doe",
            cvv="123",
            strict=False)

        # safe check
        assert_true(credit_card.is_valid())

        # check the type
        assert_equals(test_cc_type, credit_card.card_type)
def test_valid():
    """test if a credit card number is luhn valid"""
    for test_cc_type, test_cc_num in test_cards.items():
        # create a credit card object
        credit_card = CreditCard(
                number = test_cc_num, # invalid credit card
                exp_mo = "12",
                exp_yr = "2019",
                first_name = "John",
                last_name = "Doe",
                cvv = "123",
                strict = False
        )

        # safe check
        assert_true(credit_card.is_valid())

        # check the type
        assert_equals(test_cc_type, credit_card.card_type)
Exemple #14
0
def test_valid():
    """test if a credit card number is luhn valid"""
    for test_cc_type, test_cc_num in TEST_CARDS.items():
        # create a credit card object
        credit_card = CreditCard(
                number = test_cc_num, # valid credit card
                exp_mo = NEXT_YEAR.strftime('%m'),
                exp_yr = NEXT_YEAR.strftime('%Y'),
                first_name = "John",
                last_name = "Doe",
                cvv = "123",
                strict = False
        )

        # safe check
        assert_true(credit_card.is_valid())

        # check the type
        assert_equals(test_cc_type, credit_card.card_type)
def test_exp_styled():
    """testing support for 2 digits expiracy year"""
    credit_card = CreditCard(
            number = '4111111111111111',
            exp_mo = '02',
            exp_yr = '2012',
            full_name = 'John Doe',
            cvv = '911',
            strict = False
    )

    credit_card._exp_yr_style = True

    # safe check
    assert_true(credit_card.is_valid())

    # checking if our str() method (or repr()) is ok
    final_str = '<CreditCard -- John Doe, visa, ************1111, expires: 02/2012 --extra: 12>'
    assert_equals(str(credit_card), final_str)