Exemplo n.º 1
0
def test_validate_luhn_check_digit(card_number: str, valid: bool):
    if valid:
        assert PaymentCardNumber.validate_luhn_check_digit(
            card_number) == card_number
    else:
        with pytest.raises(LuhnValidationError):
            PaymentCardNumber.validate_luhn_check_digit(card_number)
def test_length_for_brand(card_number: str, brand: PaymentCardBrand,
                          valid: bool):
    pcn = PCN(card_number, brand)
    if valid:
        assert PaymentCardNumber.validate_length_for_brand(pcn) == pcn
    else:
        with pytest.raises(InvalidLengthForBrand):
            PaymentCardNumber.validate_length_for_brand(pcn)
def test_get_brand(card_number: str, brand: PaymentCardBrand):
    assert PaymentCardNumber._get_brand(card_number) == brand
def test_validate_luhn_check_digit():
    assert PaymentCardNumber.validate_luhn_check_digit(
        VALID_VISA) == VALID_VISA
    with pytest.raises(LuhnValidationError):
        PaymentCardNumber.validate_luhn_check_digit(LUHN_INVALID)
def test_validate_digits():
    digits = '12345'
    assert PaymentCardNumber.validate_digits(digits) == digits
    with pytest.raises(NotDigitError):
        PaymentCardNumber.validate_digits('hello')