This repository has been archived by the owner on Dec 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incompatibility with recent factory_boy postgeneration.
- Loading branch information
Showing
1 changed file
with
7 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import factory | ||
|
||
from django.contrib.auth.models import User, Group | ||
from django.contrib.auth.hashers import make_password | ||
|
||
|
||
class GroupFactory(factory.django.DjangoModelFactory): | ||
|
@@ -17,11 +18,16 @@ class UserFactory(factory.django.DjangoModelFactory): | |
username = factory.Sequence(lambda n: 'user%s' % n) | ||
first_name = factory.Sequence(lambda n: "user %03d" % n) | ||
email = '[email protected]' | ||
password = factory.PostGenerationMethodCall('set_password', 'password') | ||
|
||
class Meta: | ||
model = User | ||
|
||
@factory.post_generation | ||
def password(self, create, extracted, **kwargs): | ||
if not create: | ||
return | ||
return make_password('password') | ||
|
||
@factory.post_generation | ||
def groups(self, create, extracted, **kwargs): | ||
if not create: | ||
|