summaryrefslogtreecommitdiff
path: root/tests/test_django.py
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2013-09-25 10:58:12 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-09-25 10:58:12 +0200
commit2e5046bda818771f474a1514465f71bd62be9dcd (patch)
treeade9d0c6f02fbc4dfbe066b41c6765c215a68f81 /tests/test_django.py
parentea00fa30273c7355c02a361c1193ea4764528edb (diff)
downloadfactory-boy-2e5046bda818771f474a1514465f71bd62be9dcd.tar
factory-boy-2e5046bda818771f474a1514465f71bd62be9dcd.tar.gz
Fix Django sequences with abstract base models.
Diffstat (limited to 'tests/test_django.py')
-rw-r--r--tests/test_django.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_django.py b/tests/test_django.py
index b27562c..7cebf8d 100644
--- a/tests/test_django.py
+++ b/tests/test_django.py
@@ -64,6 +64,8 @@ else: # pragma: no cover
models = Fake()
models.StandardModel = Fake
+ models.AbstractBase = Fake
+ models.ConcreteSon = Fake
models.NonIntegerPk = Fake
models.WithFile = Fake
models.WithImage = Fake
@@ -106,6 +108,17 @@ class NonIntegerPkFactory(factory.django.DjangoModelFactory):
bar = ''
+class AbstractBaseFactory(factory.django.DjangoModelFactory):
+ FACTORY_FOR = models.AbstractBase
+ ABSTRACT_FACTORY = True
+
+ foo = factory.Sequence(lambda n: "foo%d" % n)
+
+
+class ConcreteSonFactory(AbstractBaseFactory):
+ FACTORY_FOR = models.ConcreteSon
+
+
class WithFileFactory(factory.django.DjangoModelFactory):
FACTORY_FOR = models.WithFile
@@ -224,6 +237,14 @@ class DjangoNonIntegerPkTestCase(django_test.TestCase):
@unittest.skipIf(django is None, "Django not installed.")
+class DjangoAbstractBaseSequenceTestCase(django_test.TestCase):
+ def test_auto_sequence(self):
+ with factory.debug():
+ obj = ConcreteSonFactory()
+ self.assertEqual(1, obj.pk)
+
+
+@unittest.skipIf(django is None, "Django not installed.")
class DjangoFileFieldTestCase(unittest.TestCase):
def tearDown(self):