Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
Fix incompatibility with recent factory_boy postgeneration.
Browse files Browse the repository at this point in the history
  • Loading branch information
jezdez committed Feb 19, 2018
1 parent 31aad71 commit 1560bf7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion atmo/users/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down

0 comments on commit 1560bf7

Please sign in to comment.