def test_nl_BE_ssn_valid(self): from faker.providers.ssn.nl_BE import Provider provider = Provider(None) for i in range(1000): ssn = provider.ssn() self.assertEqual(len(ssn), 11) gen_ssn_base = ssn[0:6] gen_seq = ssn[6:9] gen_chksum = ssn[9:11] gen_ssn_base_as_int = int(gen_ssn_base) gen_seq_as_int = int(gen_seq) gen_chksum_as_int = int(gen_chksum) # Check that the sequence nr is between 1 inclusive and 998 inclusive self.assertGreater(gen_seq_as_int, 0) self.assertLessEqual(gen_seq_as_int, 998) # validate checksum calculation # Since the century is not part of ssn, try both below and above year 2000 ssn_below = int(ssn[0:9]) chksum_below = 97 - (ssn_below % 97) ssn_above = ssn_below + 2000000000 chksum_above = 97 - (ssn_above % 97) results = [chksum_above, chksum_below] self.assertIn(gen_chksum_as_int, results)
def test_nl_BE_ssn_valid(self): from faker.providers.ssn.nl_BE import Provider provider = Provider(None) for i in range (1000): ssn = provider.ssn() self.assertEqual(len(ssn), 11) gen_ssn_base = ssn[0:6] gen_seq = ssn[6:9] gen_chksum = ssn[9:11] gen_ssn_base_as_int = int(gen_ssn_base) gen_seq_as_int = int(gen_seq) gen_chksum_as_int = int(gen_chksum) # Check that the sequence nr is between 1 inclusive and 998 inclusive self.assertGreater(gen_seq_as_int,0) self.assertLessEqual(gen_seq_as_int, 998) # validate checksum calculation # Since the century is not part of ssn, try both below and above year 2000 ssn_below = int(ssn[0:9]) chksum_below = 97 - (ssn_below % 97) ssn_above = ssn_below + 2000000000 chksum_above = 97 - (ssn_above % 97) results = [ chksum_above, chksum_below ] self.assertIn(gen_chksum_as_int,results)
def test_us_ssn_valid(self): from faker.providers.ssn.en_US import Provider provider = Provider(self.generator) for i in range(1000): ssn = provider.ssn() assert len(ssn) == 11 assert ssn[0] != '9' assert ssn[0:3] != '666' assert ssn[0:3] != '000' assert ssn[4:6] != '00' assert ssn[7:11] != '0000'
def test_us_ssn_valid(self): from faker.providers.ssn.en_US import Provider provider = Provider(self.generator) for i in range(1000): ssn = provider.ssn() self.assertEqual(len(ssn), 11) self.assertNotEqual(ssn[0], '9') self.assertNotEqual(ssn[0:3], '666') self.assertNotEqual(ssn[0:3], '000') self.assertNotEqual(ssn[4:6], '00') self.assertNotEqual(ssn[7:11], '0000')
def test_us_ssn_valid(self): from faker.providers.ssn.en_US import Provider provider = Provider(self.generator) for i in range(1000): ssn = provider.ssn() self.assertEqual(len(ssn), 11) self.assertNotEqual(ssn[0], '9') self.assertNotEqual(ssn[0:3], '666') self.assertNotEqual(ssn[0:3], '000') self.assertNotEqual(ssn[4:6], '00') self.assertNotEqual(ssn[7:11], '0000')
def test_us_ssn_valid(self): from faker.providers.ssn.en_US import Provider provider = Provider(self.generator) for i in range(1000): ssn = provider.ssn() assert len(ssn) == 11 assert ssn[0] != '9' assert ssn[0:3] != '666' assert ssn[0:3] != '000' assert ssn[4:6] != '00' assert ssn[7:11] != '0000'