aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/users/tests/factories.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ctrack/users/tests/factories.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/ctrack/users/tests/factories.py b/ctrack/users/tests/factories.py
index 595c6a6..54fa2d5 100644
--- a/ctrack/users/tests/factories.py
+++ b/ctrack/users/tests/factories.py
@@ -22,6 +22,15 @@ class UserFactory(DjangoModelFactory):
).generate(extra_kwargs={})
self.set_password(password)
+ @post_generation
+ def groups(self, create, extracted, **kwargs):
+ """We need to allow this user to have groups added to it for permissions."""
+ if not create:
+ return
+ if extracted:
+ for group in extracted:
+ self.groups.add(group)
+
class Meta:
model = get_user_model()
django_get_or_create = ["username"]