From 9d76a3c52b8310726ec09e0262813f0438c21df6 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Sun, 19 Jan 2020 15:57:06 +0000 Subject: init commit - from cookiecutter --- ctrack/users/tests/factories.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 ctrack/users/tests/factories.py (limited to 'ctrack/users/tests/factories.py') 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"] -- cgit v1.2.3