def test_random_recipe_view_200(self): self.authenticate() recipe = Recipe(**self.recipe_data) recipe.save() response = self.client.get(reverse('recipe-random')) self.assertRedirects( response, reverse('recipe-detail', kwargs={'pk': recipe.id}))
def test_edit_view_get_200(self): self.authenticate() recipe = Recipe(**self.recipe_data) recipe.save() response = self.client.get( reverse('recipe-edit', kwargs={'pk': recipe.id})) self.assertEqual(response.status_code, 200)
def test_requires_auth(self): recipe = Recipe(**self.recipe_data) recipe.save() response = self.client.get( reverse('recipe-delete', kwargs={'pk': recipe.id})) self.assertRedirects( response, reverse('login') + "?next=" + reverse('recipe-delete', kwargs={'pk': recipe.id}))
def test_recipe_str(self): recipe_name = "New recipe name" recipe_data = self.recipe_data recipe_data.update({'name': recipe_name}) recipe = Recipe(**recipe_data) self.assertEqual(recipe_name, str(recipe))
def test_requires_auth(self): Recipe(**self.recipe_data).save() response = self.client.get(reverse('recipe-random')) self.assertRedirects( response, reverse('login') + "?next=" + reverse('recipe-random'))