-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ [#558] Test new delete endpoint for new lists
- Loading branch information
1 parent
4236b52
commit 06c8d5e
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
backend/src/openarchiefbeheer/destruction/tests/endpoints/test_destructionlist.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from rest_framework import status | ||
from rest_framework.reverse import reverse | ||
from rest_framework.test import APITestCase | ||
|
||
from openarchiefbeheer.accounts.tests.factories import UserFactory | ||
|
||
from ...constants import ListStatus | ||
from ...models import DestructionList | ||
from ..factories import DestructionListFactory | ||
|
||
|
||
class DestructionListViewsetTests(APITestCase): | ||
def test_not_record_manager_cannot_delete(self): | ||
user = UserFactory.create(post__can_start_destruction=False) | ||
|
||
destruction_list = DestructionListFactory.create(status=ListStatus.new) | ||
|
||
self.client.force_login(user) | ||
response = self.client.delete( | ||
reverse( | ||
"api:destructionlist-detail", kwargs={"uuid": destruction_list.uuid} | ||
) | ||
) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) | ||
|
||
def test_list_not_new_cannot_be_deleted(self): | ||
user = UserFactory.create(post__can_start_destruction=True) | ||
|
||
destruction_list = DestructionListFactory.create( | ||
status=ListStatus.ready_to_review | ||
) | ||
|
||
self.client.force_login(user) | ||
response = self.client.delete( | ||
reverse( | ||
"api:destructionlist-detail", kwargs={"uuid": destruction_list.uuid} | ||
) | ||
) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) | ||
|
||
def test_record_manager_can_delete_new_list(self): | ||
user = UserFactory.create(post__can_start_destruction=True) | ||
|
||
destruction_list = DestructionListFactory.create(status=ListStatus.new) | ||
list_uuid = destruction_list.uuid | ||
|
||
self.client.force_login(user) | ||
response = self.client.delete( | ||
reverse( | ||
"api:destructionlist-detail", kwargs={"uuid": destruction_list.uuid} | ||
) | ||
) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) | ||
self.assertFalse(DestructionList.objects.filter(uuid=list_uuid).exists()) |