def test_generate_create(self): obj = factory.generate(FakeDjangoModel, factory.CREATE_STRATEGY, foo='bar') self.assertEqual(obj.id, 1) self.assertEqual(obj.foo, 'bar')
def test_generate_stub(self): obj = factory.generate(FakeDjangoModel, factory.STUB_STRATEGY, foo='bar') self.assertFalse(hasattr(obj, 'id')) self.assertEqual(obj.foo, 'bar')
def test_generate_build(self): obj = factory.generate(FakeDjangoModel, factory.BUILD_STRATEGY, foo='bar') self.assertEqual(obj.id, None) self.assertEqual(obj.foo, 'bar')
def test_generate_stub(self): obj = factory.generate(FakeModel, factory.STUB_STRATEGY, foo='bar') self.assertFalse(hasattr(obj, 'id')) self.assertEqual(obj.foo, 'bar')
def test_generate_create(self): obj = factory.generate(FakeModel, factory.CREATE_STRATEGY, foo='bar') self.assertEqual(obj.id, 2) self.assertEqual(obj.foo, 'bar')
def test_generate_build(self): obj = factory.generate(FakeModel, factory.BUILD_STRATEGY, foo='bar') self.assertEqual(obj.id, None) self.assertEqual(obj.foo, 'bar')
def test_generate_create_custom_base(self): obj = factory.generate(FakeModel, factory.CREATE_STRATEGY, foo='bar', FACTORY_CLASS=factory.DjangoModelFactory) self.assertEqual(obj.id, 2) self.assertEqual(obj.foo, 'bar')