示例#1
0
def test_number_credit_card_jcb_extractor():
    jcb15 = fake.credit_card_number(card_type='jcb15')
    jcb16 = fake.credit_card_number(card_type='jcb16')
    jcbs = [jcb15, jcb16]
    _paragraph = fake.paragraph_with_salt(jcbs)
    extracted_jcbs = extractors.credit_card(_paragraph, host='JCB')
    assert compare_2_list(jcbs, extracted_jcbs)
示例#2
0
def test_number_credit_card_visa_extractor():
    visa13 = fake.credit_card_number(card_type='visa13')
    visa16 = fake.credit_card_number(card_type='visa16')
    visa19 = fake.credit_card_number(card_type='visa19')
    visas = [visa13, visa16, visa19]
    _paragraph = fake.paragraph_with_salt(visas)
    extractor_visas = extractors.credit_card(_paragraph, host='Visa')
    assert compare_2_list(visas, extractor_visas)
示例#3
0
def test_number_credit_card_discover_extractor():
    discovers = [
        fake.credit_card_number(card_type='discover') for _ in range(3)
    ]
    _paragraph = fake.paragraph_with_salt(discovers)
    extracted_discovers = extractors.credit_card(_paragraph, host='Discover')
    assert compare_2_list(discovers, extracted_discovers)
示例#4
0
def test_number_credit_card_with_number_credit_card_validator_all_type():
    card_type = random.choice(('visa13', 'visa16', 'visa19', 'mastercard',
                               'diners', 'jcb15', 'jcb16', 'discover'))
    value = fake.credit_card_number(card_type=card_type)
    ret = validators.credit_card(value, host=None)

    assert ret, value
示例#5
0
def test_number_credit_card_master_card_extractor():
    mastercards = [
        fake.credit_card_number(card_type='mastercard') for _ in range(3)
    ]
    _paragraph = fake.paragraph_with_salt(mastercards)
    extracted_mastercards = extractors.credit_card(_paragraph,
                                                   host='Master Card')
    assert compare_2_list(mastercards, extracted_mastercards)
示例#6
0
def test_number_credit_card_all_type_extractor():
    card_type = random.choice(('visa13', 'visa16', 'visa19', 'mastercard',
                               'diners', 'jcb15', 'jcb16', 'discover'))
    value = fake.credit_card_number(card_type=card_type)
    ret = extractors.credit_card(value, host=None)
    assert ret, value
    numbers = {
        'Visa': [
            fake.credit_card_number(
                card_type=random.choice(['visa13', 'visa16', 'visa19']))
        ],
        'Master Card': [fake.credit_card_number(card_type='mastercard')],
        'Diners Club': [fake.credit_card_number(card_type='diners')],
        'Discover': [fake.credit_card_number(card_type='discover')],
        'JCB':
        [fake.credit_card_number(card_type=random.choice(['jcb15', 'jcb16']))]
    }
    random_number = random.choice(list(numbers.items()))
    _paragraph = fake.paragraph_with_salt([random_number[1][0]])
    extracted = extractors.credit_card(_paragraph, host=None)
    assert random_number[1][0] in extracted[random_number[0]]
示例#7
0
def test_number_credit_card_with_host_invalid():
    value = fake.credit_card_number()
    with pytest.raises(ValueError):
        assert extractors.credit_card(value, host=fake.word())
示例#8
0
def test_number_credit_card_with_number_credit_card_validator_if_card_type_jcb16(
):
    value = fake.credit_card_number(card_type='jcb16')
    ret = validators.credit_card(value, host='JCB')

    assert ret
示例#9
0
def test_number_credit_card_with_number_credit_card_validator_if_card_type_discover(
):
    value = fake.credit_card_number(card_type='discover')
    ret = validators.credit_card(value, host='Discover')

    assert ret
示例#10
0
def test_number_credit_card_with_number_credit_card_validator_if_card_type_diner_club(
):
    value = fake.credit_card_number(card_type='diners')
    ret = validators.credit_card(value, host='Diners Club')

    assert ret
示例#11
0
def test_number_credit_card_with_number_credit_card_validator_if_card_type_master_card(
):
    value = fake.credit_card_number(card_type='mastercard')
    ret = validators.credit_card(value, host='Master Card')
    assert ret, value
示例#12
0
def test_number_credit_card_with_number_credit_card_validator_if_card_type_visa_19(
):
    value = fake.credit_card_number(card_type='visa19')
    ret = validators.credit_card(value, host='Visa')

    assert ret