Skip to content

Commit

Permalink
Arreglados tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekmo committed Jun 11, 2019
1 parent d72e7e0 commit 8baf77d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions admin_auto_tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import factory
from django.contrib.auth import get_user_model
from model_mommy import mommy

try:
from django.core.urlresolvers import reverse
except:
Expand All @@ -27,11 +29,15 @@ class AdminTestMixIn(object):

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 = create_factory(model, follow_fk=follow_fk, generate_fk=generate_fk,
field_values=field_values)()
field_values = field_values or self.field_values or {}
# instance = self.create_factory(model)(**field_values)
instance = mommy.make(model, **field_values)
return instance

def create_factory(self, model=None):
model = model or self.model
return create_factory(model)

def create_user(self, is_staff=False, is_superuser=False, is_active=True):
return self.create(model=get_user_model(), field_values=dict(
is_staff=is_staff, is_superuser=is_superuser, is_active=is_active
Expand Down Expand Up @@ -74,7 +80,7 @@ def get_delete_url(self, instance=None):
args=(instance.pk,))

def create_instance_data(self):
instance = self.create(False)
instance = self.create()
return {x: y for x, y in filter(lambda x: x[1], model_to_dict(instance).items())
if not x in self.form_data_exclude_fields}

Expand Down

0 comments on commit 8baf77d

Please sign in to comment.