From 55ccb6fa93cfcacd4b13cd21638a089dbb36cf31 Mon Sep 17 00:00:00 2001 From: Debjeet Singha <51025635+debjeetsingha@users.noreply.github.com> Date: Thu, 17 Oct 2024 00:32:23 +0530 Subject: [PATCH] Added person provider for `gu_IN` locale with tests (#2111) --- faker/providers/person/gu_IN/__init__.py | 157 +++++++++++++++++++++++ tests/providers/test_person.py | 63 +++++++++ 2 files changed, 220 insertions(+) create mode 100644 faker/providers/person/gu_IN/__init__.py diff --git a/faker/providers/person/gu_IN/__init__.py b/faker/providers/person/gu_IN/__init__.py new file mode 100644 index 0000000000..fffd4aa0da --- /dev/null +++ b/faker/providers/person/gu_IN/__init__.py @@ -0,0 +1,157 @@ +from .. import Provider as PersonProvider + + +class Provider(PersonProvider): + + formats_male = ( + "{{first_name_male}} {{last_name}}", + "{{prefix_male}} {{first_name_male}} {{last_name}}", + ) + + formats_female = ( + "{{first_name_female}} {{last_name}}", + "{{prefix_female}} {{first_name_female}} {{last_name}}", + ) + + formats = ( + "{{first_name}} {{last_name}}", + "{{prefix}} {{first_name}} {{last_name}}", + ) + + # names taken from https://www.behindthename.com/names/gender/feminine/usage/gujarati + first_names_female = ( + "અંકિતા", + "અવની", + "હીરા", + "કાજલ", + "કિરણ", + "નેહા", + "નિશા", + "પૂજા", + "પ્રાચી", + "પ્રીતિ", + "પ્રીતિ", + "પૂજા", + "રચના", + "રાધીકા", + "શ્રેયા", + "શ્વેતા", + "સોનલ", + "તન્વી", + "તેજલ", + "ઉર્વી", + "વર્ષા", + ) + + # names taken from https://www.behindthename.com/names/gender/masculine/usage/gujarati + first_names_male = ( + "અભિષેક", + "અજય", + "અક્ષય", + "આનંદ", + "અનિલ", + "અંકિત", + "અર્જુન", + "અરુણ", + "આશિષ", + "અશોક", + "ભારત", + "બ્રિજેશ", + "ચેતન", + "ચિરાગ", + "દર્શન", + "દીપા", + "દીપક", + "ધવલ", + "દિલીપ", + "દિનેશ", + "દીપા", + "દીપક", + "હરીશ", + "હર્ષ", + "હર્ષલ", + "હીરા", + "જગદીશ", + "જય", + "જયેશ", + "જિતેન્દ્ર", + "કાજલ", + "કમલ", + "કરણ", + "કિરણ", + "કિશન", + "કૃષ્ણ", + "કુમાર", + "કુનાલ", + "મહેન્દ્ર", + "મહેશ", + "મનોજ", + "મયૂર", + "મિતુલ", + "મુકેશ", + "નરેન્દ્ર", + "નીરજ", + "નિખિલ", + "નીરજ", + "નીરવ", + "નિશાંત", + "નિતિન", + "પંકજ", + "પાર્થ", + "પ્રકાશ", + "પ્રણવ", + "પ્રતિક", + "પ્રતિક", + "પ્રવીણ", + "પ્રવીણ", + "રાહુલ", + "રાજ", + "રાજેન્દ્ર", + "રાજેશ", + "રાકેશ", + "રમેશ", + "રવિ", + "રોહિત", + "સચિન", + "સમીર", + "સમીર", + "સંદિપ", + "સંદિપ", + "સંજય", + "સંજીવ", + "સંજીવ", + "શેખર", + "સિદ્ધાર્થ", + "સુભાષ", + "સુનીલ", + "સૂરજ", + "તુષાર", + "વસંત", + "વિક્રમ", + "વિપુલ", + "વિરાજ", + "વિશાલ", + "વિવેક", + "યશ", + ) + + first_names = first_names_female + first_names_male + + # last names taken from https://surnames.behindthename.com/names/usage/gujarati + last_names = ( + "ચૌધરી", + "ચૌધરી", + "ગઢવી", + "ગુપ્તા", + "જૈન", + "જોષી", + "કુમાર", + "પટેલ", + "શર્મા", + ) + + prefixes_female = ("શ્રીમતી", "કુમારી") + + prefixes_male = ("શ્રી", "શ્રીમન") + + prefixes = prefixes_female + prefixes_male diff --git a/tests/providers/test_person.py b/tests/providers/test_person.py index 16bf309ecf..bd5afc3c51 100644 --- a/tests/providers/test_person.py +++ b/tests/providers/test_person.py @@ -20,6 +20,7 @@ from faker.providers.person.fi_FI import Provider as FiProvider from faker.providers.person.fr_BE import Provider as FrBEProvider from faker.providers.person.ga_IE import Provider as GaIEProvider +from faker.providers.person.gu_IN import Provider as GuINProvider from faker.providers.person.he_IL import Provider as HeILProvider from faker.providers.person.hi_IN import Provider as HiINProvider from faker.providers.person.hy_AM import Provider as HyAmProvider @@ -673,6 +674,68 @@ def setUp(self): Faker.seed(0) +class TestGuIN(unittest.TestCase): + """Tests person in the gu_IN locale""" + + def setUp(self): + self.fake = Faker("gu_IN") + Faker.seed(0) + + """Verify that gender specific names are set correctly""" + + def test_first_name(self): + name = self.fake.first_name() + self.assertIsInstance(name, str) + assert name in GuINProvider.first_names + + def test_first_name_male(self): + name = self.fake.first_name_male() + self.assertIsInstance(name, str) + assert name in GuINProvider.first_names_male + + def test_first_name_female(self): + name = self.fake.first_name_female() + self.assertIsInstance(name, str) + assert name in GuINProvider.first_names_female + + def test_last_name(self): + last_name = self.fake.last_name() + self.assertIsInstance(last_name, str) + assert last_name in GuINProvider.last_names + + def test_name(self): + name = self.fake.name().split() + assert all(isinstance(n, str) for n in name) + if len(name) == 3: + assert all( + [ + name[0] in GuINProvider.prefixes, + name[1] in GuINProvider.first_names, + name[2] in GuINProvider.last_names, + ] + ) + else: + assert name[0] in GuINProvider.first_names + assert name[-1] in GuINProvider.last_names + + """Verify that gender specific prefixes are set correctly""" + + def test_prefix(self): + prefix = self.fake.prefix() + self.assertIsInstance(prefix, str) + assert prefix in GuINProvider.prefixes + + def test_prefix_female(self): + prefix = self.fake.prefix_female() + self.assertIsInstance(prefix, str) + assert prefix in GuINProvider.prefixes_female + + def test_prefix_male(self): + prefix = self.fake.prefix_male() + self.assertIsInstance(prefix, str) + assert prefix in GuINProvider.prefixes_male + + class TestHeIL(unittest.TestCase): """Tests person in the he_IL locale."""