summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polyconseil.fr>2013-04-16 08:10:51 +0200
committerRaphaël Barrois <raphael.barrois@polyconseil.fr>2013-04-16 08:10:51 +0200
commit9e17f7ef95f7951d7373d9f0f197dd21ac077725 (patch)
tree7b703619395135bda43d214569ed3f8cf6d175f6
parentf35579bd37594b1d888e07db79bdd77a68f4f897 (diff)
downloadfactory-boy-9e17f7ef95f7951d7373d9f0f197dd21ac077725.tar
factory-boy-9e17f7ef95f7951d7373d9f0f197dd21ac077725.tar.gz
Add more tests for DjangoModelFactoryTestCase.
-rw-r--r--tests/test_using.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_using.py b/tests/test_using.py
index c46bf2f..9e9e6aa 100644
--- a/tests/test_using.py
+++ b/tests/test_using.py
@@ -1758,5 +1758,26 @@ class ListTestCase(unittest.TestCase):
],
], o.two)
+
+class DjangoModelFactoryTestCase(unittest.TestCase):
+ def test_sequence(self):
+ class TestModelFactory(factory.DjangoModelFactory):
+ FACTORY_FOR = TestModel
+
+ a = factory.Sequence(lambda n: 'foo_%s' % n)
+
+ o1 = TestModelFactory()
+ o2 = TestModelFactory()
+
+ self.assertEqual('foo_2', o1.a)
+ self.assertEqual('foo_3', o2.a)
+
+ o3 = TestModelFactory.build()
+ o4 = TestModelFactory.build()
+
+ self.assertEqual('foo_4', o3.a)
+ self.assertEqual('foo_5', o4.a)
+
+
if __name__ == '__main__':
unittest.main()