test(core): fix factories (#229)

This commit is contained in:
Sumit Singh 2022-09-26 02:18:03 +05:30 committed by GitHub
parent c34388e6c9
commit e507dd5814
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,20 +1,21 @@
from django.contrib.auth import get_user_model
import factory
from django.contrib.auth import get_user_model
from factory import post_generation
from factory.django import DjangoModelFactory
from .models import Service
class UserFactory(DjangoModelFactory):
username = factory.Faker("user_name")
email = factory.Faker("email")
name = factory.Faker("name")
first_name = factory.Faker("name")
@post_generation
def password(self, create, extracted, **kwargs):
password = (
extracted
if extracted
else factory.Faker(
or factory.Faker(
"password",
length=42,
special_chars=True,
@ -23,6 +24,7 @@ class UserFactory(DjangoModelFactory):
lower_case=True,
).evaluate(None, None, extra={"locale": None})
)
self.set_password(password)
class Meta: