Skip to content
This repository
Browse code

Adds test to NonAbstract model inheritance

  • Loading branch information...
commit 9a66d5c654f91c49a074add909e41c8761da6823 1 parent 2d12b9d
Bernardo Fontes berinhard authored committed
3  test/generic/models.py
@@ -159,3 +159,6 @@ class SchoolEnrollment(models.Model):
159 159 start_date = models.DateField(auto_now_add=True)
160 160 school = models.ForeignKey(School)
161 161 student = models.ForeignKey(Person)
  162 +
  163 +class NonAbstractPerson(Person):
  164 + pass
8 test/generic/tests/test_mommy.py
@@ -11,7 +11,7 @@
11 11 from test.generic.models import UnsupportedModel, DummyGenericRelationModel
12 12 from test.generic.models import DummyNullFieldsModel, DummyBlankFieldsModel
13 13 from test.generic.models import DummyDefaultFieldsModel
14   -from test.generic.models import DummyGenericForeignKeyModel
  14 +from test.generic.models import DummyGenericForeignKeyModel, NonAbstractPerson
15 15
16 16
17 17 class ModelFinderTest(TestCase):
@@ -80,6 +80,12 @@ def test_prepare_one_should_not_persist_one_object(self):
80 80 self.assertEqual(Person.objects.all().count(), 0)
81 81 self.assertEqual(person.id, None)
82 82
  83 + def test_non_abstract_model_creation(self):
  84 + person = mommy.make(NonAbstractPerson, name='bob', happy=False)
  85 + self.assertIsInstance(person, NonAbstractPerson)
  86 + self.assertEqual('bob', person.name)
  87 + self.assertFalse(person.happy)
  88 +
83 89
84 90 class MommyRepeatedCreatesSimpleModel(TestCase):
85 91

0 comments on commit 9a66d5c

Please sign in to comment.
Something went wrong with that request. Please try again.