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