From 9e17f7ef95f7951d7373d9f0f197dd21ac077725 Mon Sep 17 00:00:00 2001 From: Raphaƫl Barrois Date: Tue, 16 Apr 2013 08:10:51 +0200 Subject: Add more tests for DjangoModelFactoryTestCase. --- tests/test_using.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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() -- cgit v1.2.3