diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-01-19 15:57:06 +0000 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-01-19 15:57:06 +0000 |
commit | 9d76a3c52b8310726ec09e0262813f0438c21df6 (patch) | |
tree | 4acf47dce6c3aa75f8ad7c5cb56fe6486c2d64a7 /ctrack/users/tests/factories.py |
init commit - from cookiecutter
Diffstat (limited to 'ctrack/users/tests/factories.py')
-rw-r--r-- | ctrack/users/tests/factories.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ctrack/users/tests/factories.py b/ctrack/users/tests/factories.py new file mode 100644 index 0000000..b537136 --- /dev/null +++ b/ctrack/users/tests/factories.py @@ -0,0 +1,27 @@ +from typing import Any, Sequence + +from django.contrib.auth import get_user_model +from factory import DjangoModelFactory, Faker, post_generation + + +class UserFactory(DjangoModelFactory): + + username = Faker("user_name") + email = Faker("email") + name = Faker("name") + + @post_generation + def password(self, create: bool, extracted: Sequence[Any], **kwargs): + password = Faker( + "password", + length=42, + special_chars=True, + digits=True, + upper_case=True, + lower_case=True, + ).generate(extra_kwargs={}) + self.set_password(password) + + class Meta: + model = get_user_model() + django_get_or_create = ["username"] |