def test_foreign_keys_fail(self): chef_gusteau = factory.make('tests.Chef', fields={'last_name': 'Gusteau'}) self.assertRaises( ForeignKeyError, factory.build, 'tests.Pizza', ) factory.build('tests.Pizza', fields={ 'chef': chef_gusteau, }) chef_skinner = factory.build('tests.Chef', fields={ 'last_name': 'Skinner', }) self.assertRaises(ForeignKeyError, factory.build, 'tests.Pizza', fields={ 'chef': chef_skinner, }) factory.build('tests.Pizza', fields={ 'chef': chef_gusteau, 'critic': None, })
def test_foreign_keys_fail(self): chef_gusteau = factory.make("tests.Chef", fields={"last_name": "Gusteau"}) self.assertRaises(ForeignKeyError, factory.build, "tests.Pizza") factory.build("tests.Pizza", fields={"chef": chef_gusteau}) chef_skinner = factory.build("tests.Chef", fields={"last_name": "Skinner"}) self.assertRaises( ForeignKeyError, factory.build, "tests.Pizza", fields={"chef": chef_skinner} ) factory.build("tests.Pizza", fields={"chef": chef_gusteau, "critic": None})
def test_build(self): chef_masters = factory.build( "tests.Chef", fields={"first_name": "Chef {}", "last_name": Lazy("first_name")}, quantity=10, ) for chef in chef_masters: self.assertEqual(chef.id, None)
def test_build(self): chef_masters = factory.build('tests.Chef', fields={ 'first_name': 'Chef {}', 'last_name': Lazy('first_name') }, quantity=10) for chef in chef_masters: self.assertEqual(chef.id, None)
def test_build(self): chef_masters = factory.build( 'tests.Chef', fields={ 'first_name': 'Chef {}', 'last_name': Lazy('first_name') }, quantity=10) for chef in chef_masters: self.assertEqual(chef.id, None)
def test_foreign_keys_fail(self): chef_gusteau = factory.make( 'tests.Chef', fields={ 'first_name': 'Gusteau' } ) self.assertRaises(ForeignKeyError, factory.build, 'tests.Pizza', ) factory.build( 'tests.Pizza', fields={ 'chef': chef_gusteau, } ) chef_skinner = factory.build( 'tests.Chef', fields={ 'first_name': 'Skinner', } ) self.assertRaises(ForeignKeyError, factory.build, 'tests.Pizza', fields={ 'chef': chef_skinner, } ) factory.build( 'tests.Pizza', fields={ 'chef': chef_gusteau, 'critic': None, } )
def test_user_create(self): url = reverse('simpl_users_api:user-list') obj = factory.build('simpl_users.User', make_fks=True) payload = serializers.UserSerializer(obj).data # Does this api work without basic or token auth? response = self.client.post(url, payload, format='json') self.assertEqual(response.status_code, 401) # Does this api work with auth? with self.login(email=self.user.email): response = self.client.post(url, payload, format='json') self.assertEqual(response.status_code, 201) self.assertNotEqual(len(response.data), 0)