Skip to content

Commit

Permalink
Re-deploy due to a server reboot.
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkoov committed Jun 7, 2024
1 parent a449559 commit 47d8c5b
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 61 deletions.
39 changes: 31 additions & 8 deletions backend/recipes/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

class RecipeTests(APITestCase):
api_client = APIClient()
another_api_client = APIClient()
prefix = "/api/"
tags_url = f"{prefix}tags/"
ingredients_url = f"{prefix}ingredients/"
Expand All @@ -54,6 +55,13 @@ class RecipeTests(APITestCase):
"last_name": "User",
"password": "wHat~Eva^_",
}
another_user_data = {
"email": "another@user.com",
"username": "another_user",
"first_name": "AnotherTest",
"last_name": "User",
"password": "wEva_$",
}

recipe_data = {
"name": "TestMe recipe",
Expand Down Expand Up @@ -440,22 +448,24 @@ def test_recipe_patch(self):
},
)
# 403
# response = self.client.patch(
# self.log_in_and_tokenize_another_user()
# response = self.api_client.patch(
# f"{self.recipes_url}{id_}/", patch_data, format="json"
# )
# self.assertEqual(
# response.status_code,
# status.HTTP_403_FORBIDDEN,
# "Must be the 403 status code!",
# )
# self.log_out_and_detokenize_user()

self.log_in_and_tokenize_user()
patch_data["ingredients"] = None
patch_data["name"] = None
response = self.api_client.patch(
f"{self.recipes_url}{id_}/", patch_data, format="json"
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
# self.log_in_and_tokenize_user()
# patch_data["ingredients"] = None
# patch_data["name"] = None
# response = self.api_client.patch(
# f"{self.recipes_url}{id_}/", patch_data, format="json"
# )
# self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

def test_list_recipes(self):
response = self.client.get(self.recipes_url)
Expand Down Expand Up @@ -598,6 +608,19 @@ def log_in_and_tokenize_user(cls):
token = Token.objects.get(user__username=cls.user_data["username"])
cls.api_client.credentials(HTTP_AUTHORIZATION="Token " + token.key)

# @classmethod
# def log_in_and_tokenize_another_user(cls):
# login_data = {
# "password": cls.another_user_data["password"],
# "email": cls.another_user_data["email"],
# }
# response = cls.another_api_client.post(
# cls.login_url, login_data, format="json"
# )
# assert "auth_token" in json.loads(response.content)
# # token = Token.objects.get(user__username=cls.user_data["username"])
# # cls.api_client.credentials(HTTP_AUTHORIZATION="Token " + token.key)

@classmethod
def log_out_and_detokenize_user(cls):
response = cls.api_client.post(cls.logout_url, format="json")
Expand Down
106 changes: 53 additions & 53 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 47d8c5b

Please sign in to comment.