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)
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)
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)
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)
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]]
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())
def test_number_credit_card_with_number_invalid(): value = fake.text() ret = extractors.credit_card(value, host=None) assert ret is None