test(core): fix factories (#229)
This commit is contained in:
parent
c34388e6c9
commit
e507dd5814
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user