Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Gender.MALE,
],
)
def test_patronymic(russia, gender):
result = russia.patronymic(gender=gender)
assert result is not None
assert len(result) >= 4
with pytest.raises(NonEnumerableError):
russia.patronymic(gender='nil')
Gender.MALE,
],
)
def test_first_name(self, person, gender):
result = person.first_name(gender=gender)
assert result in person._data['names'][gender.value]
(Gender.MALE, 'male'),
(Gender.FEMALE, 'female'),
(None, ['female', 'male']),
],
)
def test_validate_enum(self, base_data_provider, gender, excepted):
result = base_data_provider._validate_enum(gender, Gender)
assert (result == excepted) or (result in excepted)
assert result in [item.value for item in Gender]
with pytest.raises(NonEnumerableError):
base_data_provider._validate_enum('', '')
Gender.MALE,
Gender.FEMALE,
],
)
def test_credit_card_owner(self, payment, gender):
result = payment.credit_card_owner(gender=gender)
assert isinstance(result, dict)
assert 'owner' in result
assert 'credit_card' in result
assert 'expiration_date' in result
def test_surname(self, p1, p2):
assert p1.surname() == p2.surname()
assert p1.last_name(gender=Gender.MALE) == \
p2.last_name(gender=Gender.MALE)
def person(locale=None):
if locale is None:
locales = _MIMESIS_LOCALES
else:
locales = [locale]
p = mimesis.Person(locale=choice(locales))
gender = choice(['Male'] * 20 + ['Female'] * 21 + ['Other'])
g = mimesis.enums.Gender.MALE if gender.lower() == 'male' else mimesis.enums.Gender.FEMALE
first = p.name(g)
last = p.last_name(g)
return {
'first_name': first,
'last_name': last,
'name': first + ' ' + last, # western
'age': p.age(),
'gender': gender,
'id': p.identifier(),
'occupation': p.occupation(),
'telephone': p.telephone(),
'title': p.title(g),
'username': p.username(),
'university': p.university(),
}
if 1800 <= year <= 1899:
month += 80
elif 2000 <= year <= 2099:
month += 20
elif 2100 <= year <= 2199:
month += 40
elif 2200 <= year <= 2299:
month += 60
pesel_digits += [int(d) for d in '{:02d}'.format(month)]
pesel_digits += [int(d) for d in '{:02d}'.format(day)]
series_number = self.random.randint(0, 999)
pesel_digits += [int(d) for d in '{:03d}'.format(series_number)]
if gender == Gender.MALE:
gender_digit = self.random.choice((1, 3, 5, 7, 9))
elif gender == Gender.FEMALE:
gender_digit = self.random.choice((0, 2, 4, 6, 8))
else:
gender_digit = self.random.choice(range(10))
pesel_digits.append(gender_digit)
pesel_coeffs = (9, 7, 3, 1, 9, 7, 3, 1, 9, 7)
sum_v = sum([nc * nd for nc, nd in
zip(pesel_coeffs, pesel_digits)])
checksum_digit = sum_v % 10
pesel_digits.append(checksum_digit)
return ''.join(str(d) for d in pesel_digits)