diff --git a/greg/tests/populate_database.py b/greg/tests/populate_database.py index c86d746b3e2419c18283c47b6295119c254e973e..3ac357ebcfb90b8c0a12d867f204fded6386b310 100644 --- a/greg/tests/populate_database.py +++ b/greg/tests/populate_database.py @@ -28,6 +28,8 @@ class DatabasePopulation: faker: Faker persons: List[Person] = [] + emails: List[Identity] = [] + phones: List[Identity] = [] units: List[OrganizationalUnit] = [] sponsors: List[Sponsor] = [] role_types: List[RoleType] = [] @@ -52,13 +54,26 @@ class DatabasePopulation: first_name = self.faker.first_name() last_name = self.faker.last_name() - self.persons.append( - Person.objects.create( - first_name=first_name, - last_name=last_name, - date_of_birth=self.faker.date_of_birth(maximum_age=50), - email=f"{first_name}.{last_name}@example.org", - mobile_phone=self.faker.phone_number(), + person = Person.objects.create( + first_name=first_name, + last_name=last_name, + date_of_birth=self.faker.date_of_birth(maximum_age=50), + ) + self.persons.append(person) + self.emails.append( + Identity.objects.create( + person=person, + type=Identity.IdentityType.PRIVATE_EMAIL, + value=f"{first_name}.{last_name}@example.org", + source=self.faker.company(), + ) + ) + self.phones.append( + Identity.objects.create( + person=person, + type=Identity.IdentityType.PRIVATE_MOBILE_NUMBER, + value=self.faker.phone_number(), + source=self.faker.company(), ) ) @@ -147,7 +162,7 @@ class DatabasePopulation: Role.objects.create( person=random.choice(self.persons), type=random.choice(self.role_types), - unit=random.choice(self.units), + orgunit_id=random.choice(self.units), start_date=self.faker.date_this_decade(), end_date=self.faker.date_this_decade( before_today=False, after_today=True