Skip to content

Commit

Permalink
Replaced AutoFixture with Factory Boy.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekmo committed Jun 10, 2019
1 parent 602fdfc commit d72e7e0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions admin_auto_tests/test_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest import SkipTest

from autofixture import AutoFixture
import factory
from django.contrib.auth import get_user_model
try:
from django.core.urlresolvers import reverse
Expand All @@ -13,15 +13,23 @@
from admin_auto_tests.utils import test_base_class


def create_factory(model_class, **kwargs):
class Factory(factory.django.DjangoModelFactory):
class Meta:
model = model_class

return Factory


class AdminTestMixIn(object):
field_values = None
model = None

def create(self, commit=True, model=None, follow_fk=True, generate_fk=True, field_values=None):
model = model or self.model
field_values = field_values or self.field_values
instance = AutoFixture(model, follow_fk=follow_fk, generate_fk=generate_fk,
field_values=field_values).create_one(commit)
instance = create_factory(model, follow_fk=follow_fk, generate_fk=generate_fk,
field_values=field_values)()
return instance

def create_user(self, is_staff=False, is_superuser=False, is_active=True):
Expand Down

0 comments on commit d72e7e0

Please sign in to comment.