コード例 #1
0
 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}))
コード例 #2
0
 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)
コード例 #3
0
 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}))
コード例 #4
0
ファイル: tests.py プロジェクト: Chirurgus/cookbox
    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))
コード例 #5
0
 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'))