Skip to content

Commit

Permalink
correction categoties
Browse files Browse the repository at this point in the history
  • Loading branch information
romanmyko committed Dec 13, 2024
1 parent 93b9026 commit dbc68db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion BackEnd/administration/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def filter_is_deleted(self, queryset, name, value):

class CategoriesFilter(FilterSet):
"""
manage categori filter
manage categories filter
"""

id = filters.CharFilter(lookup_expr="icontains")
Expand Down
12 changes: 6 additions & 6 deletions BackEnd/administration/tests/test_admin_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def tearDown(self):
AdminCategoryFactory.reset_sequence(0)
AdminProfileFactory.reset_sequence(0)

def test_get_categoryes_users_staff(self):
def test_get_categories_users_staff(self):
self.client.force_authenticate(self.user)
response = self.client.get(path="/api/admin/categories/")
data = [
Expand All @@ -71,37 +71,37 @@ def test_get_categoryes_users_staff(self):
self.assertEqual(data, response.json()["results"])
self.assertEqual(status.HTTP_200_OK, response.status_code)

def test_get_categoryes_id_users_staff(self):
def test_get_categories_id_users_staff(self):
self.client.force_authenticate(self.user)
response = self.client.get(path="/api/admin/categories/3/")
data = {"name": "category 1"}
self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(data, response.json())

def test_post_new_categoryes_users_staff(self):
def test_post_new_categories_users_staff(self):
self.client.force_authenticate(self.user)
data = {"name": "category 11"}
response = self.client.post(path="/api/admin/categories/", data=data)
self.assertEqual(status.HTTP_201_CREATED, response.status_code)
self.assertEqual(response.json()["name"], data["name"])
self.assertIn("id", response.json())

def test_post_unique_categoryes_users_staff(self):
def test_post_unique_categories_users_staff(self):
self.client.force_authenticate(self.user)
data = {"name": "category 1"}
message = "Category with this name already exists."
response = self.client.post(path="/api/admin/categories/", data=data)
self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code)
self.assertEqual(response.json()["name"][0], message)

def test_put_categoryes_id_users_staff(self):
def test_put_categories_id_users_staff(self):
self.client.force_authenticate(self.user)
data = {"name": "category 1212"}
response = self.client.put(path="/api/admin/categories/14/", data=data)
self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(response.json()["name"], data["name"])

def test_patch_categoryes_id_users_staff(self):
def test_patch_categories_id_users_staff(self):
self.client.force_authenticate(self.user)
data = {"name": "category 77"}
response = self.client.patch(
Expand Down

0 comments on commit dbc68db

Please sign in to comment.