Skip to content

Commit 3d29a9c

Browse files
committed
✅ [#262] Test ordering on processing status
1 parent f092150 commit 3d29a9c

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

backend/src/openarchiefbeheer/destruction/tests/test_endpoints.py

+36-1
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ def test_filter_items_on_destruction_list(self):
858858

859859
self.client.force_authenticate(user=record_manager)
860860
endpoint = furl(reverse("api:destruction-list-items-list"))
861-
endpoint.args["destruction_list"] = destruction_list.pk
861+
endpoint.args["destruction_list"] = str(destruction_list.uuid)
862862

863863
response = self.client.get(
864864
endpoint.url,
@@ -870,6 +870,41 @@ def test_filter_items_on_destruction_list(self):
870870

871871
self.assertEqual(data["count"], 2)
872872

873+
def test_order_on_processing_status(self):
874+
record_manager = UserFactory.create(username="record_manager")
875+
destruction_list = DestructionListFactory.create()
876+
item1 = DestructionListItemFactory.create(
877+
status=ListItemStatus.suggested,
878+
destruction_list=destruction_list,
879+
processing_status=InternalStatus.succeeded,
880+
)
881+
item2 = DestructionListItemFactory.create(
882+
status=ListItemStatus.suggested,
883+
destruction_list=destruction_list,
884+
processing_status=InternalStatus.processing,
885+
)
886+
item3 = DestructionListItemFactory.create(
887+
status=ListItemStatus.suggested,
888+
destruction_list=destruction_list,
889+
processing_status=InternalStatus.failed,
890+
)
891+
892+
self.client.force_authenticate(user=record_manager)
893+
endpoint = furl(reverse("api:destruction-list-items-list"))
894+
endpoint.args["destruction_list"] = str(destruction_list.uuid)
895+
896+
response = self.client.get(
897+
endpoint.url,
898+
)
899+
900+
self.assertEqual(response.status_code, status.HTTP_200_OK)
901+
902+
data = response.json()
903+
904+
self.assertEqual(data["results"][0]["pk"], item3.pk)
905+
self.assertEqual(data["results"][1]["pk"], item2.pk)
906+
self.assertEqual(data["results"][2]["pk"], item1.pk)
907+
873908

874909
class DestructionListReviewViewSetTest(APITestCase):
875910
def test_no_auth(self):

0 commit comments

Comments
 (0)