diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2012-01-06 23:39:33 +0100 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2012-01-06 23:39:33 +0100 |
commit | 8563a98022b8b3e855bf036a57aad4fd86319eff (patch) | |
tree | 282264bb40e9aef33f2489b018275735a943ce54 /tests/test_base.py | |
parent | 105f2fe021a71e1f03650e3bcdd657152fe19a20 (diff) | |
download | factory-boy-8563a98022b8b3e855bf036a57aad4fd86319eff.tar factory-boy-8563a98022b8b3e855bf036a57aad4fd86319eff.tar.gz |
Add factory.build(), factory.create(), factory.stub() methods.
Those are shortcuts for writing a full Factory class.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'tests/test_base.py')
-rw-r--r-- | tests/test_base.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_base.py b/tests/test_base.py index 01855c3..5855682 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -55,6 +55,27 @@ class SafetyTestCase(unittest.TestCase): self.assertRaises(RuntimeError, base.BaseFactory) +class SimpleBuildTestCase(unittest.TestCase): + """Tests the minimalist 'factory.build/create' functions.""" + + def test_build(self): + obj = base.build(TestObject, two=2) + self.assertEqual(obj.one, None) + self.assertEqual(obj.two, 2) + self.assertEqual(obj.three, None) + self.assertEqual(obj.four, None) + + def test_create(self): + obj = base.create(FakeDjangoModel, foo='bar') + self.assertEqual(obj.id, 1) + self.assertEqual(obj.foo, 'bar') + + def test_stub(self): + obj = base.stub(TestObject, three=3) + self.assertEqual(obj.three, 3) + self.assertFalse(hasattr(obj, 'two')) + + class FactoryTestCase(unittest.TestCase): def testAttribute(self): class TestObjectFactory(base.Factory): |