Skip to content

Commit

Permalink
Update test factories to use latest factory_boy
Browse files Browse the repository at this point in the history
  • Loading branch information
LilyFoote committed Jun 16, 2015
1 parent 654e4dc commit 8bb829d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ colour-runner==0.0.4
coverage==3.7.1
dj-database-url==0.3.0
dj-inmemorystorage==1.3.0
factory_boy==2.4.1
factory_boy==2.5.2
flake8==2.3.0
flake8-import-order==0.5.1
incuna-test-utils==6.0.0
Expand Down
10 changes: 6 additions & 4 deletions user_management/models/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@


class UserFactory(factory.DjangoModelFactory):
FACTORY_FOR = get_user_model()

name = factory.Sequence('Test User {}'.format)
email = factory.Sequence('email{}@example.com'.format)
is_active = True

class Meta:
model = get_user_model()

@factory.post_generation
def password(self, create, extracted='default password', **kwargs):
self.raw_password = extracted
Expand All @@ -21,7 +22,8 @@ def password(self, create, extracted='default password', **kwargs):


class AuthTokenFactory(factory.DjangoModelFactory):
FACTORY_FOR = AuthToken

key = factory.Sequence('key{}'.format)
user = factory.SubFactory(UserFactory)

class Meta:
model = AuthToken

0 comments on commit 8bb829d

Please sign in to comment.