🩹(factory) handle email uniqueness
When generating a batch of users using Faker, there's a possibility of generating multiple users with the same email address. This breaches the uniqueness constraint set on the email field, leading to flaky tests that may fail when random behavior coincides unfavorably. Implemented a method inspired by Identity's model to ensure unique email addresses when creating user batches with Faker. Updated relevant tests for improved stability.
This commit is contained in:
committed by
aleb_the_flash
parent
99cee241f9
commit
97752e1d5f
@@ -124,6 +124,7 @@ class UserFactory(factory.django.DjangoModelFactory):
|
||||
|
||||
class Meta:
|
||||
model = models.User
|
||||
django_get_or_create = ("email",)
|
||||
|
||||
email = factory.Faker("email")
|
||||
language = factory.fuzzy.FuzzyChoice([lang[0] for lang in settings.LANGUAGES])
|
||||
|
||||
Reference in New Issue
Block a user