Skip to content

Commit

Permalink
test(api): mv test case change denied delete to apipermissionchange t…
Browse files Browse the repository at this point in the history
…est cases

this test only works when there is a change user, so it's belongs with change use test cases.

ref: #426
  • Loading branch information
jon-nfc committed Dec 21, 2024
1 parent 6498b63 commit 1c06560
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
32 changes: 16 additions & 16 deletions app/api/tests/abstract/api_permissions_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,22 @@ def test_change_has_permission(self):
assert response.status_code == 200


def test_delete_permission_change_denied(self):
""" Check correct permission for delete
Attempt to delete as user with change permission only
"""

client = Client()
url = reverse(self.app_namespace + ':' + self.url_name + '-detail', kwargs=self.url_view_kwargs)


client.force_login(self.change_user)
response = client.delete(url, data=self.delete_data)

assert response.status_code == 403



class APIPermissionDelete:

Expand Down Expand Up @@ -468,22 +484,6 @@ def test_delete_permission_add_denied(self):
assert response.status_code == 403


def test_delete_permission_change_denied(self):
""" Check correct permission for delete
Attempt to delete as user with change permission only
"""

client = Client()
url = reverse(self.app_namespace + ':' + self.url_name + '-detail', kwargs=self.url_view_kwargs)


client.force_login(self.change_user)
response = client.delete(url, data=self.delete_data)

assert response.status_code == 403


def test_delete_has_permission(self):
""" Check correct permission for delete
Expand Down
2 changes: 2 additions & 0 deletions app/api/urls_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
index as assistance_index_v2,
knowledge_base as knowledge_base_v2,
knowledge_base_category as knowledge_base_category_v2,
model_knowledge_base_article,
request as request_ticket_v2,
)

Expand Down Expand Up @@ -107,6 +108,7 @@

router.register('assistance', assistance_index_v2.Index, basename='_api_v2_assistance_home')
router.register('assistance/knowledge_base', knowledge_base_v2.ViewSet, basename='_api_v2_knowledge_base')
router.register('assistance/(?P<model>.+)/(?P<model_pk>[0-9]+)/knowledge_base', model_knowledge_base_article.ViewSet, basename='_api_v2_model_kb')
router.register('assistance/ticket/request', request_ticket_v2.ViewSet, basename='_api_v2_ticket_request')


Expand Down

0 comments on commit 1c06560

Please sign in to comment.