Skip to content

Commit

Permalink
move factories out from package since this has no models
Browse files Browse the repository at this point in the history
  • Loading branch information
crccheck committed Nov 27, 2014
1 parent 9611eaa commit d9bef16
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
19 changes: 0 additions & 19 deletions django_object_actions/factories.py

This file was deleted.

2 changes: 1 addition & 1 deletion django_object_actions/tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.test import TestCase

from example_project.polls.factories import UserFactory
from example_project.polls.models import Choice
from ..factories import UserFactory


class LoggedInTestCase(TestCase):
Expand Down
18 changes: 18 additions & 0 deletions example_project/polls/factories.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
try:
from django.contrib.auth import get_user_model
except ImportError: # pragma: no cover
# Django 1.4
from django.contrib.auth.models import User
get_user_model = lambda: User

import factory

from . import models


class UserFactory(factory.DjangoModelFactory):
FACTORY_FOR = get_user_model()
first_name = factory.Sequence(lambda i: u'John{0}'.format(i))
last_name = factory.Sequence(lambda i: u'Doe{0}'.format(i))
username = factory.LazyAttribute(lambda x: '{0}{1}'.format(
x.first_name, x.last_name))
email = factory.LazyAttribute(lambda x: '{0}@{1}.com'.format(
x.first_name.lower(), x.last_name.lower()))
password = factory.PostGenerationMethodCall('set_password', 'password')


class CommentFactory(factory.DjangoModelFactory):
FACTORY_FOR = models.Comment

0 comments on commit d9bef16

Please sign in to comment.