diff --git a/arkindex/documents/serializers/elements.py b/arkindex/documents/serializers/elements.py index 7e08129b4bad21e35cad8293a2381c2f30e17143..bd9ef10be06b64157c47e1fa6b3c5856c486123f 100644 --- a/arkindex/documents/serializers/elements.py +++ b/arkindex/documents/serializers/elements.py @@ -944,7 +944,7 @@ class ElementBulkSerializer(serializers.Serializer): class ElementChildrenCreateSerializer(serializers.Serializer): - children = serializers.ListField(child=serializers.UUIDField()) + children = serializers.ListField(child=serializers.UUIDField(), allow_empty=False) def validate_children(self, children): # Ignore duplicates, but preserve order. diff --git a/arkindex/documents/tests/test_bulk_children.py b/arkindex/documents/tests/test_bulk_children.py index 803d90202a44031ca49713abef45865721bbdc5f..ea4cc6ab8153780af25d45efb292eee869286015 100644 --- a/arkindex/documents/tests/test_bulk_children.py +++ b/arkindex/documents/tests/test_bulk_children.py @@ -69,7 +69,7 @@ class TestElementChildrenCreate(FixtureAPITestCase): ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), { - "children": ["This field is required."], + "children": ["This list may not be empty."], }) def test_parent_not_found(self): diff --git a/arkindex/documents/tests/test_bulk_classification.py b/arkindex/documents/tests/test_bulk_classification.py index 4b2b13fc3b75ceb98cfa9fe5b5941cf7f3833fbd..bad2fc1dec1dd2d2d1e4ed7829acd32bd2da8e0f 100644 --- a/arkindex/documents/tests/test_bulk_classification.py +++ b/arkindex/documents/tests/test_bulk_classification.py @@ -23,7 +23,7 @@ class TestBulkClassification(FixtureAPITestCase): cls.cat_class = cls.corpus.ml_classes.create(name="cat") def test_requires_login(self): - response = self.client.post(reverse("api:classification-bulk"), format="json") + response = self.client.post(reverse("api:classification-bulk")) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @patch("arkindex.users.managers.BaseACLManager.filter_rights") @@ -39,7 +39,6 @@ class TestBulkClassification(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.post( reverse("api:classification-bulk"), - format="json", data={ "parent": str(private_page.id), "worker_run_id": str(self.local_worker_run.id), @@ -68,7 +67,6 @@ class TestBulkClassification(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.post( reverse("api:classification-bulk"), - format="json", data={ "parent": str(self.page.id), "classifications": [ @@ -94,7 +92,6 @@ class TestBulkClassification(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:classification-bulk"), - format="json", data={ "parent": str(self.page.id), "classifications": [ @@ -124,7 +121,6 @@ class TestBulkClassification(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.post( reverse("api:classification-bulk"), - format="json", data={ "parent": str(self.page.id), "worker_run_id": str(self.local_worker_run.id), @@ -150,7 +146,6 @@ class TestBulkClassification(FixtureAPITestCase): with self.assertNumQueries(7): response = self.client.post( reverse("api:classification-bulk"), - format="json", data={ "parent": str(self.page.id), "classifications": [ @@ -175,7 +170,6 @@ class TestBulkClassification(FixtureAPITestCase): with self.assertNumQueries(7): response = self.client.post( reverse("api:classification-bulk"), - format="json", data={ "parent": str(self.page.id), "classifications": [ @@ -210,7 +204,6 @@ class TestBulkClassification(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.post( reverse("api:classification-bulk"), - format="json", data={ "parent": str(self.page.id), "worker_run_id": str(self.local_worker_run.id), @@ -239,7 +232,6 @@ class TestBulkClassification(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:classification-bulk"), - format="json", data={ "parent": str(self.page.id), "worker_run_id": str(self.worker_run.id), @@ -268,7 +260,6 @@ class TestBulkClassification(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:classification-bulk"), - format="json", data={ "parent": str(self.page.id), "worker_run_id": str(worker_run.id), @@ -302,7 +293,6 @@ class TestBulkClassification(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.post( reverse("api:classification-bulk"), - format="json", data={ "parent": str(self.page.id), "worker_run_id": str(other_worker_run.id), @@ -330,7 +320,6 @@ class TestBulkClassification(FixtureAPITestCase): with self.assertNumQueries(7): response = self.client.post( reverse("api:classification-bulk"), - format="json", data={ "parent": str(self.page.id), "classifications": [ @@ -400,7 +389,6 @@ class TestBulkClassification(FixtureAPITestCase): with self.assertNumQueries(6): response = self.client.post( reverse("api:classification-bulk"), - format="json", data={ "parent": str(self.page.id), "classifications": [ @@ -449,7 +437,6 @@ class TestBulkClassification(FixtureAPITestCase): with self.assertNumQueries(6): response = self.client.post( reverse("api:classification-bulk"), - format="json", data={ "parent": str(self.page.id), "classifications": [ diff --git a/arkindex/documents/tests/test_bulk_element_transcriptions.py b/arkindex/documents/tests/test_bulk_element_transcriptions.py index e47e5b5be9b169e3308a5b8f388f80ce0707e3c3..cfde7cbb708b25086cdc76d20669be937b307929 100644 --- a/arkindex/documents/tests/test_bulk_element_transcriptions.py +++ b/arkindex/documents/tests/test_bulk_element_transcriptions.py @@ -53,7 +53,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data=data ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -89,7 +88,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(13): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data=data ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -149,7 +147,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(13): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data=data ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -210,7 +207,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(13): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data=data ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -252,7 +248,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(13): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data=data ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -301,7 +296,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(11): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.huge_page.id}), - format="json", data=data ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -324,7 +318,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(2): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data={} ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -339,7 +332,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(2): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.private_page.id}), - format="json", data={} ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) @@ -352,7 +344,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data={ "element_type": "text_line", "transcriptions": [{ @@ -376,7 +367,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data={ "element_type": "paragraph", "worker_run_id": bad_id, @@ -445,7 +435,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(13): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data=data ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -477,7 +466,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.vol.id}), - format="json", data={} ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -512,7 +500,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(13): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": top_level.id}), - format="json", data=data ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -560,7 +547,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(13): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data=data ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -592,7 +578,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data=data ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -623,7 +608,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(13): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.rotated_page.id}), - format="json", data=data ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -660,7 +644,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(13): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.mirrored_page.id}), - format="json", data=data ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -697,7 +680,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data=data ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -713,7 +695,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data={ "parent": str(self.page.id), "element_type": "text_line", @@ -741,7 +722,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data={ "parent": str(self.page.id), "element_type": "text_line", @@ -775,7 +755,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data={ "parent": str(self.page.id), "element_type": "text_line", @@ -808,7 +787,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(12): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data={ "parent": str(self.page.id), "element_type": "text_line", @@ -848,7 +826,6 @@ class TestBulkElementTranscriptions(FixtureAPITestCase): with self.assertNumQueries(12): response = self.client.post( reverse("api:element-transcriptions-bulk", kwargs={"pk": self.page.id}), - format="json", data={ "parent": str(self.page.id), "element_type": "text_line", diff --git a/arkindex/documents/tests/test_bulk_elements.py b/arkindex/documents/tests/test_bulk_elements.py index bd72c968d6a5dc89b84429976ceb960ab813d959..c47348d9853466583d235e1fd3bb26496b4427a4 100644 --- a/arkindex/documents/tests/test_bulk_elements.py +++ b/arkindex/documents/tests/test_bulk_elements.py @@ -71,7 +71,6 @@ class TestBulkElements(FixtureAPITestCase): response = self.client.post( reverse("api:elements-bulk-create", kwargs={"pk": str(self.element.id)}), data=self.payload, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "Authentication credentials were not provided."}) @@ -83,7 +82,6 @@ class TestBulkElements(FixtureAPITestCase): response = self.client.post( reverse("api:elements-bulk-create", kwargs={"pk": str(self.element.id)}), data=self.payload, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "You do not have permission to perform this action."}) @@ -95,7 +93,6 @@ class TestBulkElements(FixtureAPITestCase): response = self.client.post( reverse("api:elements-bulk-create", kwargs={"pk": str(self.element.id)}), data=self.payload, - format="json", ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) @@ -107,7 +104,6 @@ class TestBulkElements(FixtureAPITestCase): response = self.client.post( reverse("api:elements-bulk-create", kwargs={"pk": str(self.element.id)}), data={"elements": []}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -123,7 +119,6 @@ class TestBulkElements(FixtureAPITestCase): "worker_run_id": str(self.local_worker_run.id), "elements": [], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"elements": {"non_field_errors": ["This list may not be empty."]}}) @@ -143,7 +138,6 @@ class TestBulkElements(FixtureAPITestCase): } ] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -164,7 +158,6 @@ class TestBulkElements(FixtureAPITestCase): response = self.client.post( reverse("api:elements-bulk-create", kwargs={"pk": str(self.element.id)}), data=self.payload, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -224,7 +217,6 @@ class TestBulkElements(FixtureAPITestCase): for i in range(1, 5) ] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -249,7 +241,6 @@ class TestBulkElements(FixtureAPITestCase): } ] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -272,7 +263,6 @@ class TestBulkElements(FixtureAPITestCase): response = self.client.post( reverse("api:elements-bulk-create", kwargs={"pk": str(self.rotated_page.id)}), data=self.payload, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) created_elements = Element.objects.get_descending(self.rotated_page.id) @@ -287,7 +277,6 @@ class TestBulkElements(FixtureAPITestCase): response = self.client.post( reverse("api:elements-bulk-create", kwargs={"pk": str(self.mirrored_page.id)}), data=self.payload, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) created_elements = Element.objects.get_descending(self.mirrored_page.id) @@ -343,7 +332,6 @@ class TestBulkElements(FixtureAPITestCase): response = self.client.post( reverse("api:elements-bulk-create", kwargs={"pk": str(self.element.id)}), data=payload, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -369,7 +357,6 @@ class TestBulkElements(FixtureAPITestCase): } ] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -393,7 +380,6 @@ class TestBulkElements(FixtureAPITestCase): } ] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -410,7 +396,6 @@ class TestBulkElements(FixtureAPITestCase): response = self.client.post( reverse("api:elements-bulk-create", kwargs={"pk": str(self.element.id)}), data=payload, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), {"worker_run_id": [ @@ -428,7 +413,6 @@ class TestBulkElements(FixtureAPITestCase): response = self.client.post( reverse("api:elements-bulk-create", kwargs={"pk": str(self.element.id)}), data=payload, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), {"worker_run_id": [ @@ -452,7 +436,6 @@ class TestBulkElements(FixtureAPITestCase): response = self.client.post( reverse("api:elements-bulk-create", kwargs={"pk": str(self.element.id)}), data=payload, - format="json", HTTP_AUTHORIZATION=f"Ponos {task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -469,7 +452,6 @@ class TestBulkElements(FixtureAPITestCase): response = self.client.post( reverse("api:elements-bulk-create", kwargs={"pk": str(self.element.id)}), data=self.payload, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -518,7 +500,6 @@ class TestBulkElements(FixtureAPITestCase): response = self.client.post( reverse("api:elements-bulk-create", kwargs={"pk": str(self.element.id)}), data=payload, - format="json", HTTP_AUTHORIZATION=f"Ponos {task.token}", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -565,7 +546,6 @@ class TestBulkElements(FixtureAPITestCase): response = self.client.post( reverse("api:elements-bulk-create", kwargs={"pk": str(self.element.id)}), data=payload, - format="json", HTTP_AUTHORIZATION=f"Ponos {task.token}", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) diff --git a/arkindex/documents/tests/test_bulk_transcription_entities.py b/arkindex/documents/tests/test_bulk_transcription_entities.py index 8359e3d4adde18846425736bfa7d9a2b6d71d0ef..fe8b103614a2c8734812064c7824b3d18c8a3bcf 100644 --- a/arkindex/documents/tests/test_bulk_transcription_entities.py +++ b/arkindex/documents/tests/test_bulk_transcription_entities.py @@ -63,7 +63,6 @@ class TestBulkTranscriptionEntities(FixtureAPITestCase): response = self.client.post( reverse("api:transcription-entities-bulk", kwargs={"pk": str(self.transcription.id)}), data={}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), { @@ -81,7 +80,6 @@ class TestBulkTranscriptionEntities(FixtureAPITestCase): "entities": [], "worker_run_id": str(fake_uuid), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), { @@ -113,7 +111,6 @@ class TestBulkTranscriptionEntities(FixtureAPITestCase): ], "worker_run_id": str(self.local_worker_run.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -131,7 +128,6 @@ class TestBulkTranscriptionEntities(FixtureAPITestCase): ], "worker_run_id": str(self.local_worker_run.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -162,7 +158,6 @@ class TestBulkTranscriptionEntities(FixtureAPITestCase): ], "worker_run_id": str(self.local_worker_run.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -191,7 +186,6 @@ class TestBulkTranscriptionEntities(FixtureAPITestCase): ], "worker_run_id": str(self.worker_run.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -222,7 +216,6 @@ class TestBulkTranscriptionEntities(FixtureAPITestCase): ], "worker_run_id": str(private_worker_run.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -259,7 +252,6 @@ class TestBulkTranscriptionEntities(FixtureAPITestCase): ], "worker_run_id": str(other_worker_run.id), }, - format="json", HTTP_AUTHORIZATION=f"Ponos {task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -310,7 +302,6 @@ class TestBulkTranscriptionEntities(FixtureAPITestCase): ], "worker_run_id": str(self.local_worker_run.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -378,7 +369,6 @@ class TestBulkTranscriptionEntities(FixtureAPITestCase): ], "worker_run_id": str(self.worker_run.id), }, - format="json", HTTP_AUTHORIZATION=f"Ponos {task.token}", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -413,7 +403,6 @@ class TestBulkTranscriptionEntities(FixtureAPITestCase): ], "worker_run_id": str(self.local_worker_run.id), }, - format="json", HTTP_AUTHORIZATION=f"Ponos {task.token}", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) diff --git a/arkindex/documents/tests/test_bulk_transcriptions.py b/arkindex/documents/tests/test_bulk_transcriptions.py index b94712e37591da43bb242ae9a7d9705ffd219f5e..b1b58af420ebd46f041619d619daad1a25f39848 100644 --- a/arkindex/documents/tests/test_bulk_transcriptions.py +++ b/arkindex/documents/tests/test_bulk_transcriptions.py @@ -53,7 +53,7 @@ class TestBulkTranscriptions(FixtureAPITestCase): "confidence": 0.4 } ], - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), { "transcriptions": [ @@ -87,7 +87,7 @@ class TestBulkTranscriptions(FixtureAPITestCase): "confidence": 0.85 }, ], - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { "worker_run_id": ["This field is required."] @@ -106,7 +106,7 @@ class TestBulkTranscriptions(FixtureAPITestCase): "text": "Sneasel" }, ], - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), {"transcriptions": [ {"non_field_errors": [ @@ -139,7 +139,7 @@ class TestBulkTranscriptions(FixtureAPITestCase): "confidence": 0.33 }, ], - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_201_CREATED) first_tr, second_tr = test_element.transcriptions.values_list("id", flat=True) @@ -188,7 +188,7 @@ class TestBulkTranscriptions(FixtureAPITestCase): "confidence": 0.33 }, ], - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), { "transcriptions": [ @@ -206,7 +206,6 @@ class TestBulkTranscriptions(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.post( reverse("api:transcription-bulk"), - format="json", data={ "worker_run_id": str(self.worker_run.id), "transcriptions": [ @@ -236,7 +235,6 @@ class TestBulkTranscriptions(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.post( reverse("api:transcription-bulk"), - format="json", data={ "worker_run_id": str(private_worker_run.id), "transcriptions": [ @@ -272,7 +270,6 @@ class TestBulkTranscriptions(FixtureAPITestCase): with self.assertNumQueries(2): response = self.client.post( reverse("api:transcription-bulk"), - format="json", data={ "worker_run_id": str(other_worker_run.id), "transcriptions": [ @@ -323,7 +320,7 @@ class TestBulkTranscriptions(FixtureAPITestCase): "confidence": 0.12 }, ], - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_201_CREATED) first_tr, second_tr = element1.transcriptions.values_list("id", flat=True) @@ -396,7 +393,6 @@ class TestBulkTranscriptions(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:transcription-bulk"), - format="json", data={ "worker_run_id": str(self.worker_run.id), "transcriptions": [ @@ -448,7 +444,6 @@ class TestBulkTranscriptions(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:transcription-bulk"), - format="json", data={ "worker_run_id": str(local_worker_run.id), "transcriptions": [ diff --git a/arkindex/documents/tests/test_children_elements.py b/arkindex/documents/tests/test_children_elements.py index 9515f9b9a39888c975db5a293a0457fa558c4997..98117d29fa747ccad17a4b9c7700017950393eb9 100644 --- a/arkindex/documents/tests/test_children_elements.py +++ b/arkindex/documents/tests/test_children_elements.py @@ -469,7 +469,7 @@ class TestChildrenElements(FixtureAPITestCase): [x + width, y], [x, y] ], - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json()) return self.corpus.elements.get(id=response.json()["id"]) diff --git a/arkindex/documents/tests/test_classification.py b/arkindex/documents/tests/test_classification.py index a8dd00e79b37ef31700517da94e2cb3d107ccc1a..35b6bda2f74d420b60a98b1937cc2a6691328d8c 100644 --- a/arkindex/documents/tests/test_classification.py +++ b/arkindex/documents/tests/test_classification.py @@ -70,7 +70,6 @@ class TestClassifications(FixtureAPITestCase): "ml_class": str(self.text.id), "worker_run_id": None, }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -749,7 +748,6 @@ class TestClassifications(FixtureAPITestCase): response = self.client.post( reverse("api:elements-selection"), data={"ids": [self.folder.id, self.element.id, act_x.id, act_y.id]}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -824,7 +822,6 @@ class TestClassifications(FixtureAPITestCase): self.client.post( reverse("api:elements-selection"), data={"ids": [self.folder.id, self.element.id, act_x.id]}, - format="json" ) with self.assertNumQueries(4): @@ -851,7 +848,6 @@ class TestClassifications(FixtureAPITestCase): self.client.post( reverse("api:elements-selection"), data={"ids": [self.folder.id, self.element.id]}, - format="json" ) with self.assertNumQueries(3): diff --git a/arkindex/documents/tests/test_create_elements.py b/arkindex/documents/tests/test_create_elements.py index 7dee5d25fa12c60e5d6b672c2190dc271bec7a59..2644b8120835a504bb685876c6c82cf7b42fbffe 100644 --- a/arkindex/documents/tests/test_create_elements.py +++ b/arkindex/documents/tests/test_create_elements.py @@ -562,7 +562,6 @@ class TestCreateElements(FixtureAPITestCase): "image": None, "polygon": None, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) diff --git a/arkindex/documents/tests/test_create_parent_selection.py b/arkindex/documents/tests/test_create_parent_selection.py index f60e35e3e775ee56f1697b8cf07f28981987403f..82754123b260c5497c85c4af0cda008b93172198 100644 --- a/arkindex/documents/tests/test_create_parent_selection.py +++ b/arkindex/documents/tests/test_create_parent_selection.py @@ -23,7 +23,7 @@ class TestMoveSelection(FixtureAPITestCase): response = self.client.post(reverse("api:create-parent-selection"), { "corpus_id": str(self.corpus.id), "parent_id": str(self.parent.id), - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @override_settings(ARKINDEX_FEATURES={"selection": True}) @@ -35,7 +35,7 @@ class TestMoveSelection(FixtureAPITestCase): response = self.client.post(reverse("api:create-parent-selection"), { "corpus_id": str(self.corpus.id), "parent_id": str(self.parent.id), - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @override_settings(ARKINDEX_FEATURES={"selection": False}) @@ -45,7 +45,7 @@ class TestMoveSelection(FixtureAPITestCase): response = self.client.post(reverse("api:create-parent-selection"), { "corpus_id": str(self.corpus.id), "parent_id": str(self.parent.id), - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), {"non_field_errors": ["Selection is not available on this instance."]} @@ -64,7 +64,7 @@ class TestMoveSelection(FixtureAPITestCase): response = self.client.post(reverse("api:create-parent-selection"), { "corpus_id": str(private_corpus.id), "parent_id": str(private_element.id), - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -82,7 +82,7 @@ class TestMoveSelection(FixtureAPITestCase): response = self.client.post(reverse("api:create-parent-selection"), { "corpus_id": str(self.corpus.id), "parent_id": "12341234-1234-1234-1234-123412341234" - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -97,7 +97,7 @@ class TestMoveSelection(FixtureAPITestCase): response = self.client.post(reverse("api:create-parent-selection"), { "corpus_id": str(self.corpus.id), "parent_id": str(self.page.id), - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -115,7 +115,7 @@ class TestMoveSelection(FixtureAPITestCase): response = self.client.post(reverse("api:create-parent-selection"), { "corpus_id": str(self.corpus.id), "parent_id": str(parent.id), - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -131,7 +131,7 @@ class TestMoveSelection(FixtureAPITestCase): response = self.client.post(reverse("api:create-parent-selection"), { "corpus_id": str(self.corpus.id), "parent_id": str(parent.id), - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -148,7 +148,7 @@ class TestMoveSelection(FixtureAPITestCase): response = self.client.post(reverse("api:create-parent-selection"), { "corpus_id": str(self.corpus.id), "parent_id": str(parent_id), - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -166,7 +166,7 @@ class TestMoveSelection(FixtureAPITestCase): response = self.client.post(reverse("api:create-parent-selection"), { "corpus_id": str(self.corpus.id), "parent_id": str(self.parent.id), - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(delay_mock.call_count, 1) diff --git a/arkindex/documents/tests/test_create_transcriptions.py b/arkindex/documents/tests/test_create_transcriptions.py index 1800ed9d2b9e4963794577f58425104e82eb14fc..03eae8d9ac90e0fca40ad1d7a1176754131f68fa 100644 --- a/arkindex/documents/tests/test_create_transcriptions.py +++ b/arkindex/documents/tests/test_create_transcriptions.py @@ -36,7 +36,7 @@ class TestTranscriptionCreate(FixtureAPITestCase): def test_require_login(self): with self.assertNumQueries(0): - response = self.client.post(reverse("api:transcription-create", kwargs={"pk": self.line.id}), format="json") + response = self.client.post(reverse("api:transcription-create", kwargs={"pk": self.line.id})) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), { "detail": "Authentication credentials were not provided." @@ -48,7 +48,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.private_page.id}), - format="json", data={"text": "NEKUDOTAYIM"} ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -62,7 +61,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(2): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.private_page.id}), - format="json", data={"text": "NEKUDOTAYIM"} ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) @@ -72,7 +70,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": uuid4()}), - format="json", data={"text": "NEKUDOTAYIM"} ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) @@ -82,7 +79,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.line.id}), - format="json", data={"text": "A perfect day in a perfect place"} ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -109,7 +105,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.line.id}), - format="json", data={ "text": ts.text, } @@ -128,7 +123,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.line.id}), - format="json", data={"text": "A perfect day in a perfect place", "orientation": "vertical-lr"} ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -151,7 +145,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.line.id}), - format="json", data={"text": "A perfect day in a perfect place", "orientation": "wiggly"} ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -162,7 +155,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.line.id}), - format="json", data={"text": "A classy text line"} ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -172,7 +164,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.line.id}), - format="json", data={ "text": "NEKUDOTAYIM", "worker_version": str(self.worker_version.id), @@ -199,7 +190,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.line.id}), - format="json", data={ "text": "NEKUDOTAYIM", "worker_run_id": str(self.local_worker_run.id), @@ -236,7 +226,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.line.id}), - format="json", data={ "text": "NEKUDOTAYIM", "worker_run_id": str(local_worker_run.id), @@ -271,7 +260,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.line.id}), - format="json", data={ "text": "NEKUDOTAYIM", "worker_run_id": str(self.worker_run.id), @@ -304,7 +292,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.line.id}), - format="json", data={ "text": "NEKUDOTAYIM", "worker_run_id": str(self.worker_run.id), @@ -327,7 +314,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.line.id}), - format="json", data={ "text": "NEKUDOTAYIM", "worker_run_id": str(worker_run.id), @@ -356,7 +342,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.line.id}), - format="json", data={ "text": "NEKUDOTAYIM", "worker_run_id": str(other_worker_run.id), @@ -375,7 +360,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.line.id}), - format="json", data={ "text": "NEKUDOTAYIM", "worker_run_id": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", @@ -393,7 +377,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.line.id}), - format="json", data={ "text": "CIRCLE", "worker_run_id": str(self.local_worker_run.id), @@ -414,7 +397,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": null_zone_page.id}), - format="json", data={ "text": "ELLIPSE", "confidence": .42 @@ -439,7 +421,6 @@ class TestTranscriptionCreate(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.post( reverse("api:transcription-create", kwargs={"pk": self.line.id}), - format="json", data={ "text": "CIRCLE", "type": "paragraph", diff --git a/arkindex/documents/tests/test_edit_transcriptions.py b/arkindex/documents/tests/test_edit_transcriptions.py index 92093e9a04dcfc026cbdc6c3bc93840b0db30185..b41e80b70639620b72c893cd60ea6286d8807227 100644 --- a/arkindex/documents/tests/test_edit_transcriptions.py +++ b/arkindex/documents/tests/test_edit_transcriptions.py @@ -95,7 +95,6 @@ class TestEditTranscription(FixtureAPITestCase): self.client.force_login(self.user) response = self.client.patch( reverse("api:transcription-edit", kwargs={"pk": self.manual_transcription.id}), - format="json", data={"text": "Once upon a time in a castle"} ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -108,7 +107,6 @@ class TestEditTranscription(FixtureAPITestCase): self.client.force_login(self.user) response = self.client.patch( reverse("api:transcription-edit", kwargs={"pk": self.ml_transcription.id}), - format="json", data={"text": "Once upon a time in a castle"} ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -124,7 +122,6 @@ class TestEditTranscription(FixtureAPITestCase): manual_tr_id = self.manual_transcription.id response = self.client.patch( reverse("api:transcription-edit", kwargs={"pk": manual_tr_id}), - format="json", data={ "id": uuid4(), "text": "a knight was living lonely", @@ -153,7 +150,6 @@ class TestEditTranscription(FixtureAPITestCase): manual_tr_id = self.manual_transcription.id response = self.client.patch( reverse("api:transcription-edit", kwargs={"pk": manual_tr_id}), - format="json", data={ "orientation": "vertical-rl" } @@ -176,7 +172,6 @@ class TestEditTranscription(FixtureAPITestCase): manual_tr_id = self.manual_transcription.id response = self.client.patch( reverse("api:transcription-edit", kwargs={"pk": manual_tr_id}), - format="json", data={ "orientation": "wobbly" } @@ -192,7 +187,6 @@ class TestEditTranscription(FixtureAPITestCase): self.client.force_login(self.private_read_user) response = self.client.patch( reverse("api:transcription-edit", kwargs={"pk": self.private_transcription.id}), - format="json", data={"text": "He was good and fearless"} ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -208,7 +202,6 @@ class TestEditTranscription(FixtureAPITestCase): self.client.force_login(self.write_user) response = self.client.patch( reverse("api:transcription-edit", kwargs={"pk": self.ml_transcription.id}), - format="json", data={"text": "He used to play the Bumbulum"} ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -224,7 +217,6 @@ class TestEditTranscription(FixtureAPITestCase): self.manual_transcription.transcription_entities.create(entity=self.entity, offset=0, length=1) response = self.client.patch( reverse("api:transcription-edit", kwargs={"pk": self.manual_transcription.id}), - format="json", data={"text": "One day, the king told him to go save a princess"} ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -237,7 +229,6 @@ class TestEditTranscription(FixtureAPITestCase): manual_tr_id = self.manual_transcription.id response = self.client.put( reverse("api:transcription-edit", kwargs={"pk": manual_tr_id}), - format="json", data={ "text": "a knight was living lonely", "orientation": "vertical-rl", @@ -258,7 +249,6 @@ class TestEditTranscription(FixtureAPITestCase): self.client.force_login(self.user) response = self.client.put( reverse("api:transcription-edit", kwargs={"pk": self.ml_transcription.id}), - format="json", data={"text": "Once upon a time in a castle", "orientation": "horizontal-rl"} ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -274,7 +264,6 @@ class TestEditTranscription(FixtureAPITestCase): manual_tr_id = self.manual_transcription.id response = self.client.put( reverse("api:transcription-edit", kwargs={"pk": manual_tr_id}), - format="json", data={ "text": "a knight was living lonely", "orientation": "wobbly", @@ -291,7 +280,6 @@ class TestEditTranscription(FixtureAPITestCase): self.client.force_login(self.private_read_user) response = self.client.put( reverse("api:transcription-edit", kwargs={"pk": self.private_transcription.id}), - format="json", data={"text": "He used to play the Bumbulum", "orientation": "horizontal-lr"} ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -307,7 +295,6 @@ class TestEditTranscription(FixtureAPITestCase): self.client.force_login(self.write_user) response = self.client.put( reverse("api:transcription-edit", kwargs={"pk": self.ml_transcription.id}), - format="json", data={"text": "He used to play the Bumbulum", "orientation": "horizontal-lr"} ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -323,7 +310,6 @@ class TestEditTranscription(FixtureAPITestCase): self.manual_transcription.transcription_entities.create(entity=self.entity, offset=0, length=1) response = self.client.put( reverse("api:transcription-edit", kwargs={"pk": self.manual_transcription.id}), - format="json", data={"text": "One day, the king told him to go save a princess"} ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) diff --git a/arkindex/documents/tests/test_element_paths_api.py b/arkindex/documents/tests/test_element_paths_api.py index 290d2ce63ee22a2c9874b1f6cffd460156fe9f05..29bcd793cf20a292c35363d60644fb81250e92f7 100644 --- a/arkindex/documents/tests/test_element_paths_api.py +++ b/arkindex/documents/tests/test_element_paths_api.py @@ -214,7 +214,7 @@ class TestElementsAPI(FixtureAPITestCase): [x + width, y], [x, y] ], - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json()) return self.corpus.elements.get(id=response.json()["id"]) diff --git a/arkindex/documents/tests/test_element_type.py b/arkindex/documents/tests/test_element_type.py index 37d2882b3c70a74f5e32a8a567f426f538dc6e67..f9270ebd08e2d1ecdef8e4ce175451259c48ddb0 100644 --- a/arkindex/documents/tests/test_element_type.py +++ b/arkindex/documents/tests/test_element_type.py @@ -22,7 +22,7 @@ class TestElementType(FixtureAPITestCase): "corpus": self.corpus.id, "slug": "New_element_type", "display_name": "New element type", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @patch("arkindex.users.managers.BaseACLManager.filter_rights", return_value=Corpus.objects.none()) @@ -32,7 +32,7 @@ class TestElementType(FixtureAPITestCase): "corpus": self.private_corpus.id, "slug": "New_element_type", "display_name": "New element type", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(filter_rights_mock.call_count, 1) @@ -44,7 +44,7 @@ class TestElementType(FixtureAPITestCase): "corpus": self.corpus.id, "slug": self.element_type.slug, "display_name": "New element type", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) def test_create(self): @@ -54,7 +54,7 @@ class TestElementType(FixtureAPITestCase): "corpus": self.corpus.id, "slug": "New_element_type", "display_name": "New element type", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() self.assertIn("id", data) @@ -79,7 +79,7 @@ class TestElementType(FixtureAPITestCase): "slug": "New_element_type", "display_name": "New element type", "color": "d90dc4" - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() self.assertIn("id", data) @@ -125,7 +125,6 @@ class TestElementType(FixtureAPITestCase): "display_name": "New element type", "color": color }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"color": errors}) @@ -138,7 +137,7 @@ class TestElementType(FixtureAPITestCase): "slug": "New_element_type", "display_name": "New element type", "color": "FF0000" - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.json()["color"], "FF0000") @@ -146,7 +145,7 @@ class TestElementType(FixtureAPITestCase): response = self.client.post(reverse("api:element-type", kwargs={"pk": self.element_type.id}), { "slug": "New_element_type", "display_name": "New element type", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @patch("arkindex.users.managers.BaseACLManager.filter_rights", return_value=Corpus.objects.none()) @@ -157,7 +156,7 @@ class TestElementType(FixtureAPITestCase): response = self.client.patch(reverse("api:element-type", kwargs={"pk": private_element_type.id}), { "slug": "New_element_type", "display_name": "New element type", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertEqual(filter_rights_mock.call_count, 1) @@ -168,7 +167,7 @@ class TestElementType(FixtureAPITestCase): self.client.force_login(self.superuser) response = self.client.patch(reverse("api:element-type", kwargs={"pk": self.element_type.id}), { "slug": element_type.slug, - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"slug": ["Slug must be unique"]}) @@ -177,7 +176,7 @@ class TestElementType(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.patch( reverse("api:element-type", kwargs={"pk": self.element_type.id}), - {"color": "chouquette"}, format="json" + {"color": "chouquette"}, ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"color": [ @@ -190,7 +189,7 @@ class TestElementType(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.patch( reverse("api:element-type", kwargs={"pk": self.element_type.id}), - {"color": "yellow"}, format="json" + {"color": "yellow"}, ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"color": [ @@ -221,7 +220,6 @@ class TestElementType(FixtureAPITestCase): response = self.client.patch( reverse("api:element-type", kwargs={"pk": self.element_type.id}), update_data, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) data = response.json() @@ -242,7 +240,7 @@ class TestElementType(FixtureAPITestCase): response = self.client.post(reverse("api:element-type", kwargs={"pk": self.element_type.id}), { "slug": "New_element_type", "display_name": "New element type", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @patch("arkindex.users.managers.BaseACLManager.filter_rights", return_value=Corpus.objects.none()) @@ -253,7 +251,7 @@ class TestElementType(FixtureAPITestCase): response = self.client.put(reverse("api:element-type", kwargs={"pk": private_element_type.id}), { "slug": "New_element_type", "display_name": "New element type", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertEqual(filter_rights_mock.call_count, 1) @@ -265,7 +263,7 @@ class TestElementType(FixtureAPITestCase): response = self.client.put(reverse("api:element-type", kwargs={"pk": self.element_type.id}), { "slug": element_type.slug, "display_name": "New element type", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"slug": ["Slug must be unique"]}) @@ -279,7 +277,6 @@ class TestElementType(FixtureAPITestCase): "display_name": "New element type", "color": "chouquette" }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"color": [ @@ -294,7 +291,7 @@ class TestElementType(FixtureAPITestCase): "slug": "New_element_type", "display_name": "New element type", "color": "yellow" - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"color": [ "Color should be a hexadecimal color code" @@ -307,7 +304,7 @@ class TestElementType(FixtureAPITestCase): "slug": "New_element_type", "display_name": "New element type", "color": "4287f5" - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_200_OK) data = response.json() self.element_type.refresh_from_db() diff --git a/arkindex/documents/tests/test_entities_api.py b/arkindex/documents/tests/test_entities_api.py index 70a84274e6fd3af28b85a1c7dab8a85264d0cf8c..6e04b648c00fad0207252da57cb1421879538131 100644 --- a/arkindex/documents/tests/test_entities_api.py +++ b/arkindex/documents/tests/test_entities_api.py @@ -192,7 +192,7 @@ class TestEntitiesAPI(FixtureAPITestCase): } self.client.force_login(self.user) with self.assertNumQueries(3): - response = self.client.post(reverse("api:entity-create"), data=data, format="json") + response = self.client.post(reverse("api:entity-create"), data=data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"type_id": ["“location†is not a valid UUID."]}) @@ -208,7 +208,7 @@ class TestEntitiesAPI(FixtureAPITestCase): } self.client.force_login(self.user) with self.assertNumQueries(4): - response = self.client.post(reverse("api:entity-create"), data=data, format="json") + response = self.client.post(reverse("api:entity-create"), data=data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"type_id": ['Invalid pk "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" - object does not exist.']}) @@ -225,7 +225,7 @@ class TestEntitiesAPI(FixtureAPITestCase): } self.client.force_login(self.user) with self.assertNumQueries(4): - response = self.client.post(reverse("api:entity-create"), data=data, format="json") + response = self.client.post(reverse("api:entity-create"), data=data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"type_id": [f"EntityType {str(extraneous_type.id)} does not exist in corpus Unit Tests."]}) @@ -240,7 +240,7 @@ class TestEntitiesAPI(FixtureAPITestCase): } self.client.force_login(self.user) with self.assertNumQueries(3): - response = self.client.post(reverse("api:entity-create"), data=data, format="json") + response = self.client.post(reverse("api:entity-create"), data=data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"type_id": ["This field is required."]}) @@ -255,7 +255,7 @@ class TestEntitiesAPI(FixtureAPITestCase): }, } with self.assertNumQueries(0): - response = self.client.post(reverse("api:entity-create"), data=data, format="json") + response = self.client.post(reverse("api:entity-create"), data=data) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) def test_create_entity_worker_version_ignored(self): @@ -274,7 +274,7 @@ class TestEntitiesAPI(FixtureAPITestCase): } self.client.force_login(self.user) with self.assertNumQueries(5): - response = self.client.post(reverse("api:entity-create"), data=data, format="json") + response = self.client.post(reverse("api:entity-create"), data=data) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -300,7 +300,7 @@ class TestEntitiesAPI(FixtureAPITestCase): } self.client.force_login(self.user) with self.assertNumQueries(5): - response = self.client.post(reverse("api:entity-create"), data=data, format="json") + response = self.client.post(reverse("api:entity-create"), data=data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"worker_run_id": ['Invalid pk "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" - object does not exist.']}) @@ -312,7 +312,6 @@ class TestEntitiesAPI(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.post( reverse("api:entity-create"), - format="json", data={ "name": "test", "type_id": str(self.person_type.id), @@ -340,7 +339,6 @@ class TestEntitiesAPI(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.post( reverse("api:entity-create"), - format="json", data={ "name": "test", "type_id": str(self.person_type.id), @@ -366,7 +364,6 @@ class TestEntitiesAPI(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.post( reverse("api:entity-create"), - format="json", data={ "name": "test", "type_id": str(self.person_type.id), @@ -398,7 +395,6 @@ class TestEntitiesAPI(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:entity-create"), - format="json", data={ "name": "Bunnelby", "type_id": str(self.person_type.id), @@ -430,7 +426,7 @@ class TestEntitiesAPI(FixtureAPITestCase): } self.client.force_login(self.user) with self.assertNumQueries(6): - response = self.client.post(reverse("api:entity-create"), data=data, format="json") + response = self.client.post(reverse("api:entity-create"), data=data) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -481,7 +477,6 @@ class TestEntitiesAPI(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.post( reverse("api:entity-create"), - format="json", data={ "name": "test", "type_id": str(self.person_type.id), @@ -516,7 +511,6 @@ class TestEntitiesAPI(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.post( reverse("api:entity-create"), - format="json", data={ "name": "Bunnelby", "type_id": str(self.person_type.id), @@ -543,7 +537,6 @@ class TestEntitiesAPI(FixtureAPITestCase): response = self.client.post( reverse("api:transcription-entity-create", kwargs={"pk": str(self.transcription.id)}), data=self.tr_entities_sample, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) transcription_entity = TranscriptionEntity.objects.get( @@ -570,7 +563,6 @@ class TestEntitiesAPI(FixtureAPITestCase): response = self.client.post( reverse("api:transcription-entity-create", kwargs={"pk": str(self.transcription.id)}), data=self.tr_entities_confidence_sample, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) transcription_entity = TranscriptionEntity.objects.get( @@ -597,7 +589,6 @@ class TestEntitiesAPI(FixtureAPITestCase): response = self.client.post( reverse("api:transcription-entity-create", kwargs={"pk": str(self.transcription.id)}), data=self.tr_entities_sample, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -615,7 +606,6 @@ class TestEntitiesAPI(FixtureAPITestCase): "length": 8, "worker_run_id": str(self.local_worker_run.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertDictEqual(response.json(), { @@ -640,7 +630,6 @@ class TestEntitiesAPI(FixtureAPITestCase): "length": 8, "worker_run_id": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -658,7 +647,6 @@ class TestEntitiesAPI(FixtureAPITestCase): response = self.client.post( reverse("api:transcription-entity-create", kwargs={"pk": str(self.transcription.id)}), data=self.tr_entities_sample, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -681,7 +669,6 @@ class TestEntitiesAPI(FixtureAPITestCase): "offset": 4, "length": 0 }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( @@ -700,7 +687,6 @@ class TestEntitiesAPI(FixtureAPITestCase): "length": 1, "confidence": 2.0 }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( @@ -719,7 +705,6 @@ class TestEntitiesAPI(FixtureAPITestCase): "length": 1, "confidence": -0.5 }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( @@ -744,7 +729,6 @@ class TestEntitiesAPI(FixtureAPITestCase): response = self.client.post( reverse("api:transcription-entity-create", kwargs={"pk": str(self.transcription.id)}), data=self.tr_entities_sample, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -769,7 +753,6 @@ class TestEntitiesAPI(FixtureAPITestCase): response = self.client.post( reverse("api:transcription-entity-create", kwargs={"pk": str(self.transcription.id)}), data=self.tr_entities_sample, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -799,7 +782,6 @@ class TestEntitiesAPI(FixtureAPITestCase): "length": 8, "worker_run_id": str(self.local_worker_run.id), }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -814,7 +796,6 @@ class TestEntitiesAPI(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.post( reverse("api:transcription-entity-create", kwargs={"pk": str(self.transcription.id)}), - format="json", data={ "entity": str(self.entity.id), "offset": 4, @@ -839,7 +820,6 @@ class TestEntitiesAPI(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.post( reverse("api:transcription-entity-create", kwargs={"pk": str(self.transcription.id)}), - format="json", data={ "entity": str(self.entity.id), "offset": 4, @@ -870,7 +850,6 @@ class TestEntitiesAPI(FixtureAPITestCase): with self.assertNumQueries(4): response = self.client.post( reverse("api:transcription-entity-create", kwargs={"pk": str(self.transcription.id)}), - format="json", data={ "entity": str(self.entity.id), "offset": 4, @@ -897,7 +876,6 @@ class TestEntitiesAPI(FixtureAPITestCase): with self.assertNumQueries(6): response = self.client.post( reverse("api:transcription-entity-create", kwargs={"pk": str(self.transcription.id)}), - format="json", data={ "entity": str(self.entity.id), "offset": 4, @@ -932,7 +910,6 @@ class TestEntitiesAPI(FixtureAPITestCase): with self.assertNumQueries(6): response = self.client.post( reverse("api:transcription-entity-create", kwargs={"pk": str(self.transcription.id)}), - format="json", data={ "entity": str(self.entity.id), "offset": 4, @@ -974,7 +951,6 @@ class TestEntitiesAPI(FixtureAPITestCase): "offset": 4, "length": 8, }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) transcription_entity = self.transcription.transcription_entities.filter(worker_run=None, entity=self.entity).get() @@ -997,7 +973,6 @@ class TestEntitiesAPI(FixtureAPITestCase): response = self.client.post( reverse("api:transcription-entity-create", kwargs={"pk": str(self.transcription.id)}), data=data, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) diff --git a/arkindex/documents/tests/test_entity_types.py b/arkindex/documents/tests/test_entity_types.py index 9348ee6dcce7e8d4b384d9da94728d74cc16cc19..3646aaf9a173549dc53fd06628e42e0f3111ab7c 100644 --- a/arkindex/documents/tests/test_entity_types.py +++ b/arkindex/documents/tests/test_entity_types.py @@ -39,7 +39,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): "name": "dagger one" } with self.assertNumQueries(0): - response = self.client.post(reverse("api:entity-type-create"), data=data, format="json") + response = self.client.post(reverse("api:entity-type-create"), data=data) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) def test_create_requires_verified(self): @@ -49,7 +49,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): "name": "dagger one" } with self.assertNumQueries(2): - response = self.client.post(reverse("api:entity-type-create"), data=data, format="json") + response = self.client.post(reverse("api:entity-type-create"), data=data) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual( response.json(), @@ -66,7 +66,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): self.assertEqual(self.private_corpus.entity_types.all().count(), 1) with self.assertNumQueries(2): - response = self.client.post(reverse("api:entity-type-create"), data=data, format="json") + response = self.client.post(reverse("api:entity-type-create"), data=data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( @@ -86,7 +86,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): } self.assertEqual(self.private_corpus.entity_types.all().count(), 1) with self.assertNumQueries(5): - response = self.client.post(reverse("api:entity-type-create"), data=data, format="json") + response = self.client.post(reverse("api:entity-type-create"), data=data) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(self.private_corpus.entity_types.all().count(), 2) self.assertEqual(response.json()["color"], "ff0000") @@ -121,7 +121,6 @@ class TestEntityTypesAPI(FixtureAPITestCase): "name": "dagger spare", "color": color }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"color": errors}) @@ -134,7 +133,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): "color": "FF0000" } with self.assertNumQueries(5): - response = self.client.post(reverse("api:entity-type-create"), data=data, format="json") + response = self.client.post(reverse("api:entity-type-create"), data=data) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.json()["color"], "FF0000") @@ -147,7 +146,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): } self.assertEqual(self.private_corpus.entity_types.all().count(), 1) with self.assertNumQueries(5): - response = self.client.post(reverse("api:entity-type-create"), data=data, format="json") + response = self.client.post(reverse("api:entity-type-create"), data=data) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(self.private_corpus.entity_types.all().count(), 2) self.assertEqual(response.json()["color"], "f76719") @@ -162,7 +161,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): "color": "f76719" } with self.assertNumQueries(4): - response = self.client.post(reverse("api:entity-type-create"), data=data, format="json") + response = self.client.post(reverse("api:entity-type-create"), data=data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"name": ["Entity Type with name some type already exists in corpus private."]}) @@ -174,7 +173,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): "color": "f76719" } with self.assertNumQueries(0): - response = self.client.put(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data, format="json") + response = self.client.put(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) def test_update_requires_verified(self): @@ -184,7 +183,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): "color": "f76719" } with self.assertNumQueries(2): - response = self.client.put(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data, format="json") + response = self.client.put(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual( response.json(), @@ -200,7 +199,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): } with self.assertNumQueries(4): - response = self.client.put(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data, format="json") + response = self.client.put(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual( @@ -221,7 +220,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): "color": "f76719" } with self.assertNumQueries(6): - response = self.client.put(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data, format="json") + response = self.client.put(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data) self.assertEqual(response.status_code, status.HTTP_200_OK) self.private_corpus_entity_type.refresh_from_db() self.assertEqual(self.private_corpus_entity_type.color, "f76719") @@ -235,7 +234,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): "color": "f76719" } with self.assertNumQueries(5): - response = self.client.put(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data, format="json") + response = self.client.put(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"name": ["Entity Type with name dagger spare already exists in corpus private."]}) @@ -245,7 +244,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): "color": "f76719" } with self.assertNumQueries(4): - response = self.client.put(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data, format="json") + response = self.client.put(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"name": ["This field is required."]}) @@ -256,7 +255,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): "name": "iceman" } with self.assertNumQueries(4): - response = self.client.put(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data, format="json") + response = self.client.put(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"corpus": ["It is not possible to update an Entity Type's corpus."]}) @@ -268,7 +267,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): "color": "f76719" } with self.assertNumQueries(0): - response = self.client.patch(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data, format="json") + response = self.client.patch(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) def test_partial_update_requires_verified(self): @@ -278,7 +277,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): "color": "f76719" } with self.assertNumQueries(2): - response = self.client.patch(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data, format="json") + response = self.client.patch(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual( response.json(), @@ -294,7 +293,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): } with self.assertNumQueries(4): - response = self.client.patch(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data, format="json") + response = self.client.patch(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual( @@ -315,7 +314,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): "color": "f76719" } with self.assertNumQueries(6): - response = self.client.patch(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data, format="json") + response = self.client.patch(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.json()["color"], "f76719") self.assertEqual(response.json()["name"], "dagger spare") @@ -326,7 +325,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): "color": "f76719" } with self.assertNumQueries(6): - response = self.client.patch(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data, format="json") + response = self.client.patch(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data) self.assertEqual(response.status_code, status.HTTP_200_OK) self.private_corpus_entity_type.refresh_from_db() self.assertEqual(self.private_corpus_entity_type.color, "f76719") @@ -338,7 +337,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): "corpus": str(self.corpus.id), } with self.assertNumQueries(4): - response = self.client.patch(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data, format="json") + response = self.client.patch(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), data=data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"corpus": ["It is not possible to update an Entity Type's corpus."]}) @@ -346,7 +345,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): def test_retrieve_does_not_require_login_public_project(self): with self.assertNumQueries(1): - response = self.client.get(reverse("api:entity-type-details", kwargs={"pk": self.location_type.id}), format="json") + response = self.client.get(reverse("api:entity-type-details", kwargs={"pk": self.location_type.id})) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertDictEqual(response.json(), { "id": str(self.location_type.id), @@ -360,7 +359,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): self.client.force_login(self.no_access) with self.assertNumQueries(2): - response = self.client.get(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), format="json") + response = self.client.get(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id})) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertDictEqual( @@ -374,7 +373,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): def test_retrieve(self): self.client.force_login(self.private_corpus_guest) with self.assertNumQueries(3): - response = self.client.get(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), format="json") + response = self.client.get(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id})) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.json()["color"], "ff0000") self.assertEqual(response.json()["name"], "some type") @@ -385,7 +384,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): def test_delete_requires_corpus_admin(self, has_access_mock): self.client.force_login(self.user) with self.assertNumQueries(4): - response = self.client.delete(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), format="json") + response = self.client.delete(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id})) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual( response.json(), @@ -398,7 +397,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): def test_delete(self): self.client.force_login(self.private_corpus_admin) with self.assertNumQueries(6): - response = self.client.delete(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), format="json") + response = self.client.delete(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id})) self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) with self.assertRaises(EntityType.DoesNotExist): self.private_corpus_entity_type.refresh_from_db() @@ -407,7 +406,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): Entity.objects.create(type=self.private_corpus_entity_type, corpus=self.private_corpus, name="bob") self.client.force_login(self.private_corpus_admin) with self.assertNumQueries(5): - response = self.client.delete(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), format="json") + response = self.client.delete(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id})) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"detail": ["Some entities are using this entity type."]}) @@ -415,7 +414,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): def test_list_does_not_require_login_public_project(self): with self.assertNumQueries(3): - response = self.client.get(reverse("api:corpus-entity-types", kwargs={"pk": self.corpus.id}), format="json") + response = self.client.get(reverse("api:corpus-entity-types", kwargs={"pk": self.corpus.id})) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertCountEqual(response.json()["results"], [ { @@ -449,7 +448,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): def test_list_requires_guest_private_project(self, has_access_mock): self.client.force_login(self.no_access) with self.assertNumQueries(3): - response = self.client.get(reverse("api:corpus-entity-types", kwargs={"pk": self.private_corpus.id}), format="json") + response = self.client.get(reverse("api:corpus-entity-types", kwargs={"pk": self.private_corpus.id})) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertEqual(has_access_mock.call_count, 1) @@ -460,7 +459,7 @@ class TestEntityTypesAPI(FixtureAPITestCase): type_3 = EntityType.objects.create(corpus=self.private_corpus, color="29d911", name="person") self.client.force_login(self.private_corpus_guest) with self.assertNumQueries(5): - response = self.client.get(reverse("api:corpus-entity-types", kwargs={"pk": self.private_corpus.id}), format="json") + response = self.client.get(reverse("api:corpus-entity-types", kwargs={"pk": self.private_corpus.id})) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertCountEqual(response.json()["results"], [ { diff --git a/arkindex/documents/tests/test_metadata.py b/arkindex/documents/tests/test_metadata.py index cff728b7e96384ba45ecaaff9b1d0845b47e3f50..52ce577ee58d90ca8318d19f3a479ce3854e8dd8 100644 --- a/arkindex/documents/tests/test_metadata.py +++ b/arkindex/documents/tests/test_metadata.py @@ -324,7 +324,6 @@ class TestMetaData(FixtureAPITestCase): response = self.client.post( reverse("api:element-metadata", kwargs={"pk": str(self.vol.id)}), data={"type": "location", "name": "location", "value": "Texas", "worker_run_id": non_existent_worker_run_id}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"worker_run_id": [f'Invalid pk "{non_existent_worker_run_id}" - object does not exist.']}) @@ -1062,7 +1061,6 @@ class TestMetaData(FixtureAPITestCase): response = self.client.patch( reverse("api:metadata-edit", kwargs={"pk": str(metadata.id)}), data={"entity_id": None}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK, response.json()) metadata.refresh_from_db() @@ -1279,7 +1277,6 @@ class TestMetaData(FixtureAPITestCase): "worker_run_id": str(self.worker_run.id), "metadata_list": [{"type": "text", "name": "language", "value": "Japanese"}], }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) @@ -1304,7 +1301,6 @@ class TestMetaData(FixtureAPITestCase): {"type": "numeric", "name": "numeric", "value": "42", "entity_id": str(entity.id)} ] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(self.vol.metadatas.count(), 4) # 1 added during setUp @@ -1361,7 +1357,6 @@ class TestMetaData(FixtureAPITestCase): {"type": "text", "name": "language", "value": "Chinese"}, {"type": "text", "name": "alt_language", "value": "Mandarin"} ]}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -1377,7 +1372,6 @@ class TestMetaData(FixtureAPITestCase): {"type": "text", "name": "language", "value": "Chinese"}, {"type": "text", "name": "alt_language", "value": "Mandarin"} ], "worker_run_id": non_existent_worker_run_id}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"worker_run_id": [f'Invalid pk "{non_existent_worker_run_id}" - object does not exist.']}) @@ -1396,7 +1390,6 @@ class TestMetaData(FixtureAPITestCase): response = self.client.post( reverse("api:element-metadata-bulk", kwargs={"pk": str(self.vol.id)}), data={"metadata_list": []}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -1418,7 +1411,6 @@ class TestMetaData(FixtureAPITestCase): {"type": "text", "name": "edition", "value": "Hammersmith"}, ] }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1444,7 +1436,6 @@ class TestMetaData(FixtureAPITestCase): {"type": "text", "name": "edition", "value": "Hammersmith"}, ] }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1476,7 +1467,6 @@ class TestMetaData(FixtureAPITestCase): {"type": "text", "name": "edition", "value": "Hammersmith"}, ] }, - format="json", HTTP_AUTHORIZATION=f"Ponos {task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1493,7 +1483,6 @@ class TestMetaData(FixtureAPITestCase): "id": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", }, ], "worker_run_id": str(self.local_worker_run.id)}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) md = self.vol.metadatas.get(type=MetaType.Text, name="language") @@ -1518,7 +1507,6 @@ class TestMetaData(FixtureAPITestCase): {"type": "location", "name": "not allowed", "value": "boo"}, ] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(self.vol.metadatas.count(), 2) @@ -1575,7 +1563,6 @@ class TestMetaData(FixtureAPITestCase): {"type": "location", "name": "not allowed", "value": "boo"}, ] }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1630,7 +1617,6 @@ class TestMetaData(FixtureAPITestCase): {"type": "location", "name": "location", "value": "Texas"} ] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -1656,7 +1642,6 @@ class TestMetaData(FixtureAPITestCase): {"type": "location", "name": "location", "value": "Texas"} ] }, - format="json", ) self.assertEqual(response_2.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response_2.json(), { @@ -1681,7 +1666,6 @@ class TestMetaData(FixtureAPITestCase): {"type": "text", "name": "edition", "value": "Hammersmith"}, ] }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) diff --git a/arkindex/documents/tests/test_move_element.py b/arkindex/documents/tests/test_move_element.py index d667bd311f7b4f4ce5c6040a6c06e90f555f2340..15f218083f466b277fb66442fa0380bc9f37230b 100644 --- a/arkindex/documents/tests/test_move_element.py +++ b/arkindex/documents/tests/test_move_element.py @@ -18,7 +18,7 @@ class TestMoveElement(FixtureAPITestCase): def test_move_element_requires_login(self): with self.assertNumQueries(0): - response = self.client.post(reverse("api:move-element"), {"source": str(self.source.id), "destination": str(self.destination.id)}, format="json") + response = self.client.post(reverse("api:move-element"), {"source": str(self.source.id), "destination": str(self.destination.id)}) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) def test_move_element_requires_verified(self): @@ -26,7 +26,7 @@ class TestMoveElement(FixtureAPITestCase): self.user.save() self.client.force_login(self.user) with self.assertNumQueries(2): - response = self.client.post(reverse("api:move-element"), {"source": str(self.source.id), "destination": str(self.destination.id)}, format="json") + response = self.client.post(reverse("api:move-element"), {"source": str(self.source.id), "destination": str(self.destination.id)}) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @patch("arkindex.users.managers.BaseACLManager.filter_rights", return_value=Corpus.objects.none()) @@ -38,7 +38,7 @@ class TestMoveElement(FixtureAPITestCase): self.client.force_login(self.user) with self.assertNumQueries(2): - response = self.client.post(reverse("api:move-element"), {"source": str(private_element.id), "destination": str(private_element.id)}, format="json") + response = self.client.post(reverse("api:move-element"), {"source": str(private_element.id), "destination": str(private_element.id)}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -51,7 +51,7 @@ class TestMoveElement(FixtureAPITestCase): def test_move_element_wrong_source(self): self.client.force_login(self.user) with self.assertNumQueries(4): - response = self.client.post(reverse("api:move-element"), {"source": "12341234-1234-1234-1234-123412341234", "destination": str(self.destination.id)}, format="json") + response = self.client.post(reverse("api:move-element"), {"source": "12341234-1234-1234-1234-123412341234", "destination": str(self.destination.id)}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -61,7 +61,7 @@ class TestMoveElement(FixtureAPITestCase): def test_move_element_wrong_destination(self): self.client.force_login(self.user) with self.assertNumQueries(4): - response = self.client.post(reverse("api:move-element"), {"source": str(self.source.id), "destination": "12341234-1234-1234-1234-123412341234"}, format="json") + response = self.client.post(reverse("api:move-element"), {"source": str(self.source.id), "destination": "12341234-1234-1234-1234-123412341234"}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -71,7 +71,7 @@ class TestMoveElement(FixtureAPITestCase): def test_move_element_same_source_destination(self): self.client.force_login(self.user) with self.assertNumQueries(4): - response = self.client.post(reverse("api:move-element"), {"source": str(self.source.id), "destination": str(self.source.id)}, format="json") + response = self.client.post(reverse("api:move-element"), {"source": str(self.source.id), "destination": str(self.source.id)}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -85,7 +85,7 @@ class TestMoveElement(FixtureAPITestCase): self.client.force_login(self.user) with self.assertNumQueries(4): - response = self.client.post(reverse("api:move-element"), {"source": str(self.source.id), "destination": str(destination.id)}, format="json") + response = self.client.post(reverse("api:move-element"), {"source": str(self.source.id), "destination": str(destination.id)}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -97,7 +97,7 @@ class TestMoveElement(FixtureAPITestCase): self.client.force_login(self.user) with self.assertNumQueries(5): - response = self.client.post(reverse("api:move-element"), {"source": str(self.source.id), "destination": str(destination.id)}, format="json") + response = self.client.post(reverse("api:move-element"), {"source": str(self.source.id), "destination": str(destination.id)}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -110,7 +110,7 @@ class TestMoveElement(FixtureAPITestCase): self.client.force_login(self.user) with self.assertNumQueries(6): - response = self.client.post(reverse("api:move-element"), {"source": str(source.id), "destination": str(destination_id)}, format="json") + response = self.client.post(reverse("api:move-element"), {"source": str(source.id), "destination": str(destination_id)}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -121,7 +121,7 @@ class TestMoveElement(FixtureAPITestCase): def test_move_element(self, delay_mock): self.client.force_login(self.user) with self.assertNumQueries(6): - response = self.client.post(reverse("api:move-element"), {"source": str(self.source.id), "destination": str(self.destination.id)}, format="json") + response = self.client.post(reverse("api:move-element"), {"source": str(self.source.id), "destination": str(self.destination.id)}) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(delay_mock.call_count, 1) diff --git a/arkindex/documents/tests/test_move_selection.py b/arkindex/documents/tests/test_move_selection.py index d524373efef234c5c5b7c9f82aa9f9d80698e86b..d63f4bd35e4a9b70f2d3632fd75280828b4d52f6 100644 --- a/arkindex/documents/tests/test_move_selection.py +++ b/arkindex/documents/tests/test_move_selection.py @@ -20,7 +20,7 @@ class TestMoveSelection(FixtureAPITestCase): @override_settings(ARKINDEX_FEATURES={"selection": True}) def test_move_selection_requires_login(self): with self.assertNumQueries(0): - response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": str(self.destination.id)}, format="json") + response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": str(self.destination.id)}) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @override_settings(ARKINDEX_FEATURES={"selection": True}) @@ -29,14 +29,14 @@ class TestMoveSelection(FixtureAPITestCase): self.user.save() self.client.force_login(self.user) with self.assertNumQueries(2): - response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": str(self.destination.id)}, format="json") + response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": str(self.destination.id)}) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @override_settings(ARKINDEX_FEATURES={"selection": False}) def test_move_selection_disabled(self): self.client.force_login(self.user) with self.assertNumQueries(4): - response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": str(self.destination.id)}, format="json") + response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": str(self.destination.id)}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), {"non_field_errors": ["Selection is not available on this instance."]} @@ -52,7 +52,7 @@ class TestMoveSelection(FixtureAPITestCase): self.client.force_login(self.user) with self.assertNumQueries(2): - response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(private_corpus.id), "destination": str(private_element.id)}, format="json") + response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(private_corpus.id), "destination": str(private_element.id)}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -67,7 +67,7 @@ class TestMoveSelection(FixtureAPITestCase): self.client.force_login(self.user) self.user.selected_elements.add(self.page) with self.assertNumQueries(4): - response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": "12341234-1234-1234-1234-123412341234"}, format="json") + response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": "12341234-1234-1234-1234-123412341234"}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -79,7 +79,7 @@ class TestMoveSelection(FixtureAPITestCase): self.client.force_login(self.user) self.user.selected_elements.add(self.page) with self.assertNumQueries(6): - response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": str(self.page.id)}, format="json") + response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": str(self.page.id)}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -94,7 +94,7 @@ class TestMoveSelection(FixtureAPITestCase): self.client.force_login(self.user) self.user.selected_elements.add(self.page) with self.assertNumQueries(5): - response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": str(destination.id)}, format="json") + response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": str(destination.id)}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -107,7 +107,7 @@ class TestMoveSelection(FixtureAPITestCase): self.client.force_login(self.user) self.user.selected_elements.add(self.page) with self.assertNumQueries(7): - response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": str(destination.id)}, format="json") + response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": str(destination.id)}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -121,7 +121,7 @@ class TestMoveSelection(FixtureAPITestCase): self.client.force_login(self.user) self.user.selected_elements.add(target) with self.assertNumQueries(8): - response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": str(destination_id)}, format="json") + response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": str(destination_id)}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -136,7 +136,7 @@ class TestMoveSelection(FixtureAPITestCase): another_page = self.corpus.elements.get(name="Volume 1, page 1v") self.user.selected_elements.add(another_page) with self.assertNumQueries(8): - response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": str(self.destination.id)}, format="json") + response = self.client.post(reverse("api:move-selection"), {"corpus_id": str(self.corpus.id), "destination": str(self.destination.id)}) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(delay_mock.call_count, 1) diff --git a/arkindex/documents/tests/test_patch_elements.py b/arkindex/documents/tests/test_patch_elements.py index 18354726d1096af6170f6a11fded0dd688d30a3e..5f3a37f73503a0430445c686483d5696557d3915 100644 --- a/arkindex/documents/tests/test_patch_elements.py +++ b/arkindex/documents/tests/test_patch_elements.py @@ -49,7 +49,6 @@ class TestPatchElements(FixtureAPITestCase): response = self.client.patch( reverse("api:element-retrieve", kwargs={"pk": str(self.vol.id)}), data={"name": "Untitled (2)"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual( @@ -66,7 +65,6 @@ class TestPatchElements(FixtureAPITestCase): response = self.client.patch( reverse("api:element-retrieve", kwargs={"pk": str(self.private_elt.id)}), data={"name": "Untitled (2)"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual( @@ -86,7 +84,6 @@ class TestPatchElements(FixtureAPITestCase): response = self.client.patch( reverse("api:element-retrieve", kwargs={"pk": str(self.private_elt.id)}), data={"name": "Untitled (2)"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) @@ -99,7 +96,6 @@ class TestPatchElements(FixtureAPITestCase): response = self.client.patch( reverse("api:element-retrieve", kwargs={"pk": str(self.vol.id)}), data={"name": "Untitled (2)"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.json()["name"], "Untitled (2)") @@ -127,7 +123,6 @@ class TestPatchElements(FixtureAPITestCase): "classifications": [], "worker_run": str(WorkerRun.objects.first().id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) data = response.json() @@ -151,7 +146,6 @@ class TestPatchElements(FixtureAPITestCase): data={ "polygon": [[10, 20], [10, 30], [30, 30], [30, 20], [10, 20]] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.json()["name"], self.element.name) @@ -172,7 +166,6 @@ class TestPatchElements(FixtureAPITestCase): data={ "polygon": [[10, 20], [10, 30], [30, 30], [30, 20], [10, 20]] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -188,7 +181,6 @@ class TestPatchElements(FixtureAPITestCase): data={ "image": str(self.image.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.line_2.refresh_from_db() @@ -204,7 +196,6 @@ class TestPatchElements(FixtureAPITestCase): "image": str(self.image.id), "polygon": [[10, 20], [10, 30], [30, 30], [30, 20], [10, 20]], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.vol.refresh_from_db() @@ -229,7 +220,6 @@ class TestPatchElements(FixtureAPITestCase): "image": str(bad_image.id), "polygon": [[10, 20], [10, 30], [30, 30], [30, 20], [10, 20]], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"image": ["This image does not have valid dimensions."]}) @@ -242,7 +232,6 @@ class TestPatchElements(FixtureAPITestCase): data={ "polygon": [[-10, -20], [10, 30], [30, 30], [30, 20], [10, 20]] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -261,7 +250,6 @@ class TestPatchElements(FixtureAPITestCase): data={ "polygon": [[0, 1009], [10, 30], [30, 30], [30, 20], [10, 20]] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { diff --git a/arkindex/documents/tests/test_put_elements.py b/arkindex/documents/tests/test_put_elements.py index babf90c77922d61621d8ac7c1d1287c1497d00ea..ec14c406921da715a4fccc005a48f07c5fb98231 100644 --- a/arkindex/documents/tests/test_put_elements.py +++ b/arkindex/documents/tests/test_put_elements.py @@ -42,7 +42,6 @@ class TestPutElements(FixtureAPITestCase): response = self.client.put( reverse("api:element-retrieve", kwargs={"pk": str(self.vol.id)}), data={"name": "Untitled (2)"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual( @@ -57,7 +56,6 @@ class TestPutElements(FixtureAPITestCase): response = self.client.put( reverse("api:element-retrieve", kwargs={"pk": str(self.private_elt.id)}), data={"name": "Untitled (2)"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual( @@ -76,7 +74,6 @@ class TestPutElements(FixtureAPITestCase): response = self.client.put( reverse("api:element-retrieve", kwargs={"pk": str(self.private_elt.id)}), data={"name": "Untitled (2)"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) @@ -91,7 +88,6 @@ class TestPutElements(FixtureAPITestCase): response = self.client.put( reverse("api:element-retrieve", kwargs={"pk": str(self.vol.id)}), data={"name": "Untitled (2)", "type": "text_line"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) data = response.json() @@ -122,7 +118,6 @@ class TestPutElements(FixtureAPITestCase): "classifications": [], "worker_run": str(WorkerRun.objects.first().id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) data = response.json() @@ -148,7 +143,6 @@ class TestPutElements(FixtureAPITestCase): "type": "text_line", "polygon": [[10, 20], [10, 30], [30, 30], [30, 20], [10, 20]] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.json()["name"], "Untitled (2)") @@ -173,7 +167,6 @@ class TestPutElements(FixtureAPITestCase): "type": "text_line", "polygon": [[10, 20], [10, 30], [30, 30], [30, 20], [10, 20]] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -191,7 +184,6 @@ class TestPutElements(FixtureAPITestCase): "type": "text_line", "image": str(self.image.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.element.refresh_from_db() @@ -209,7 +201,6 @@ class TestPutElements(FixtureAPITestCase): "image": str(self.image.id), "polygon": [[10, 20], [10, 30], [30, 30], [30, 20], [10, 20]], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.vol.refresh_from_db() @@ -236,7 +227,6 @@ class TestPutElements(FixtureAPITestCase): "image": str(bad_image.id), "polygon": [[10, 20], [10, 30], [30, 30], [30, 20], [10, 20]], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"image": ["This image does not have valid dimensions."]}) @@ -251,7 +241,6 @@ class TestPutElements(FixtureAPITestCase): "type": "text_line", "polygon": [[-10, -20], [10, 30], [30, 30], [30, 20], [10, 20]] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -272,7 +261,6 @@ class TestPutElements(FixtureAPITestCase): "type": "text_line", "polygon": [[10, 20], [10, 30], [30, 30], [3000, 2000], [10, 20]] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { diff --git a/arkindex/documents/tests/test_selection_api.py b/arkindex/documents/tests/test_selection_api.py index d2fc1d7bda25f8561c1c55895950aabdba46a089..4e0bdd59b49bd36575c3e2e80637c0affc76cb44 100644 --- a/arkindex/documents/tests/test_selection_api.py +++ b/arkindex/documents/tests/test_selection_api.py @@ -29,7 +29,6 @@ class TestSelectionAPI(FixtureAPITestCase): response = self.client.post( reverse("api:elements-selection"), data={"ids": [self.vol.id]}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -40,7 +39,6 @@ class TestSelectionAPI(FixtureAPITestCase): response = self.client.post( reverse("api:elements-selection"), data={"ids": [self.vol.id]}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -50,7 +48,6 @@ class TestSelectionAPI(FixtureAPITestCase): response = self.client.post( reverse("api:elements-selection"), data={"ids": [self.vol.id]}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertListEqual(response.json(), ["Selection is not available on this instance."]) @@ -69,7 +66,6 @@ class TestSelectionAPI(FixtureAPITestCase): response = self.client.post( reverse("api:elements-selection"), data={"ids": [element.id]}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -83,7 +79,6 @@ class TestSelectionAPI(FixtureAPITestCase): response = self.client.post( reverse("api:elements-selection"), data={"ids": [self.vol.id, "ffffffff-ffff-ffff-ffff-ffffffffffff"]}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -95,7 +90,6 @@ class TestSelectionAPI(FixtureAPITestCase): response = self.client.post( reverse("api:elements-selection"), data={"ids": [self.vol.id, "oh no"]}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertContains(response, "Must be a valid UUID", count=1, status_code=400) @@ -105,7 +99,6 @@ class TestSelectionAPI(FixtureAPITestCase): response = self.client.post( reverse("api:elements-selection"), data={"ids": [self.vol.id, self.page.id, self.vol.id]}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) selected = self.client.get(reverse("api:elements-selection")).json()["results"] @@ -128,7 +121,6 @@ class TestSelectionAPI(FixtureAPITestCase): response = self.client.post( reverse("api:elements-selection"), data={"ids": [self.vol.id]}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) results = response.json() @@ -143,7 +135,6 @@ class TestSelectionAPI(FixtureAPITestCase): response = self.client.post( reverse("api:elements-selection"), data={"ids": [self.vol.id, self.page.id]}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) results = response.json() @@ -165,7 +156,6 @@ class TestSelectionAPI(FixtureAPITestCase): self.client.post( reverse("api:elements-selection"), data={"ids": [self.vol.id]}, - format="json" ) response = self.client.delete(reverse("api:elements-selection"), data={"id": self.page.id}) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -177,7 +167,6 @@ class TestSelectionAPI(FixtureAPITestCase): self.client.post( reverse("api:elements-selection"), data={"ids": [self.vol.id]}, - format="json" ) response = self.client.delete(reverse("api:elements-selection"), data={"id": self.page.id}) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -187,14 +176,13 @@ class TestSelectionAPI(FixtureAPITestCase): self.client.post( reverse("api:elements-selection"), data={"ids": [self.vol.id]}, - format="json" ) response = self.client.delete(reverse("api:elements-selection"), data={"id": self.page.id}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) def test_delete_not_a_uuid(self): self.client.force_login(self.user) - response = self.client.delete(reverse("api:elements-selection"), data={"id": {"id": self.page.id, "type": "page"}}, format="json") + response = self.client.delete(reverse("api:elements-selection"), data={"id": {"id": self.page.id, "type": "page"}}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), {"id": ["Not a valid UUID."]}) @@ -210,7 +198,6 @@ class TestSelectionAPI(FixtureAPITestCase): self.client.post( reverse("api:elements-selection"), data={"ids": [self.vol.id, self.page.id]}, - format="json" ) response = self.client.get(reverse("api:elements-selection")) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -269,7 +256,6 @@ class TestSelectionAPI(FixtureAPITestCase): self.client.post( reverse("api:elements-selection"), data={"ids": [self.vol.id]}, - format="json" ) response = self.client.get(reverse("api:elements-selection")) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -284,7 +270,6 @@ class TestSelectionAPI(FixtureAPITestCase): self.client.post( reverse("api:elements-selection"), data={"ids": [self.page.id]}, - format="json" ) response = self.client.get(reverse("api:elements-selection")) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -297,7 +282,6 @@ class TestSelectionAPI(FixtureAPITestCase): self.client.post( reverse("api:elements-selection"), data={"ids": [self.vol.id, self.page.id]}, - format="json" ) response = self.client.get(reverse("api:elements-selection")) self.assertEqual(response.status_code, status.HTTP_200_OK) diff --git a/arkindex/images/tests/test_image_api.py b/arkindex/images/tests/test_image_api.py index edbeb945c12a910c501a4e0dd17d71b97602827d..f54a8b443e2c457408dea56d6c0b800972f36c51 100644 --- a/arkindex/images/tests/test_image_api.py +++ b/arkindex/images/tests/test_image_api.py @@ -716,7 +716,7 @@ class TestImageApi(FixtureAPITestCase): def test_create_image_information_bad_content(self): self.client.force_login(self.superuser) - response = self.client.post(reverse("api:iiif-info-create"), [], format="json") + response = self.client.post(reverse("api:iiif-info-create"), []) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"detail": ["Payload should be a JSON object"]}) diff --git a/arkindex/process/tests/test_create_process.py b/arkindex/process/tests/test_create_process.py index 8ebe63a0a72c0608156dc7d40de257cdda1e4300..6126e7f720c8abc5bf64c1da22645767723c7bec 100644 --- a/arkindex/process/tests/test_create_process.py +++ b/arkindex/process/tests/test_create_process.py @@ -80,7 +80,6 @@ class TestCreateProcess(FixtureAPITestCase): "element_type": "page", "load_children": True, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -135,7 +134,6 @@ class TestCreateProcess(FixtureAPITestCase): "load_children": True, "use_cache": True, }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -171,7 +169,6 @@ class TestCreateProcess(FixtureAPITestCase): "corpus": str(self.corpus.id), "element": str(self.pages.first().id), }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -180,12 +177,12 @@ class TestCreateProcess(FixtureAPITestCase): self.assertEqual(process.element, self.pages.first()) def test_create_process_requires_login(self): - response = self.client.post(reverse("api:corpus-process"), {}, format="json") + response = self.client.post(reverse("api:corpus-process"), {}) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) def test_create_process_required_fields(self): self.client.force_login(self.user) - response = self.client.post(reverse("api:corpus-process"), {}, format="json") + response = self.client.post(reverse("api:corpus-process"), {}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( response.json(), @@ -205,7 +202,6 @@ class TestCreateProcess(FixtureAPITestCase): "corpus": str(self.corpus.id), "name": "Test", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"corpus": ["You do not have an admin access to this corpus."]}) @@ -222,7 +218,6 @@ class TestCreateProcess(FixtureAPITestCase): "corpus": str(self.private_corpus.id), "name": "Test", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"corpus": ["Corpus with this ID does not exist."]}) @@ -238,7 +233,6 @@ class TestCreateProcess(FixtureAPITestCase): "corpus": str(self.corpus.id), "element_name_contains": self.pages.first().name[2:5], }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -255,7 +249,6 @@ class TestCreateProcess(FixtureAPITestCase): "element_name_contains": "B" * 300, "element_type": "C" * 100, }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -272,7 +265,6 @@ class TestCreateProcess(FixtureAPITestCase): "corpus": str(self.corpus.id), "element_type": "volume", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -292,7 +284,6 @@ class TestCreateProcess(FixtureAPITestCase): "element_type": "volume", "element_name_contains": "ahahah", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -310,7 +301,6 @@ class TestCreateProcess(FixtureAPITestCase): "corpus": str(self.corpus.id), "selection": True, }, - format="json" ) mixin = SelectionMixin() mixin.request = namedtuple("Request", "user")(self.user) @@ -331,7 +321,6 @@ class TestCreateProcess(FixtureAPITestCase): "corpus": str(self.corpus.id), "element_type": "arachnid", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -350,7 +339,6 @@ class TestCreateProcess(FixtureAPITestCase): "element": str(self.pages.first().id), "type": "page", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -363,7 +351,6 @@ class TestCreateProcess(FixtureAPITestCase): "corpus": str(self.corpus.id), "ml_class_id": str(self.ml_class.id), }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -401,7 +388,6 @@ class TestCreateProcess(FixtureAPITestCase): "corpus": str(self.corpus.id), "element": str(element.id), }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) process = Process.objects.get(element=element, mode=ProcessMode.Workers) @@ -449,7 +435,6 @@ class TestCreateProcess(FixtureAPITestCase): "element": str(self.volume.id), "selection": True, }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( @@ -466,7 +451,6 @@ class TestCreateProcess(FixtureAPITestCase): self.client.post( reverse("api:elements-selection"), data={"ids": [page.id]}, - format="json" ) response = self.client.post( reverse("api:corpus-process"), @@ -474,7 +458,6 @@ class TestCreateProcess(FixtureAPITestCase): "corpus": str(self.corpus.id), "selection": True, }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -512,7 +495,6 @@ class TestCreateProcess(FixtureAPITestCase): "corpus": str(self.corpus.id), "selection": True, }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"selection": ["Selection is not available on this instance."]}) @@ -525,7 +507,6 @@ class TestCreateProcess(FixtureAPITestCase): "corpus": str(self.corpus.id), "name": "blah", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -727,7 +708,6 @@ class TestCreateProcess(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-process"), data, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -763,7 +743,6 @@ class TestCreateProcess(FixtureAPITestCase): "mode": "dataset", "selection": True }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -783,7 +762,6 @@ class TestCreateProcess(FixtureAPITestCase): "corpus": str(self.corpus.id), "mode": mode, }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"mode": [f'"{mode}" is not a valid choice.']}) diff --git a/arkindex/process/tests/test_processes.py b/arkindex/process/tests/test_processes.py index 0b463412c1c753c7ddb7c0a5691b88a33006bd77..eceab04504b310ad6cb858837d79ef7cc53bf27e 100644 --- a/arkindex/process/tests/test_processes.py +++ b/arkindex/process/tests/test_processes.py @@ -922,7 +922,6 @@ class TestProcesses(FixtureAPITestCase): response = self.client.patch( reverse("api:process-details", kwargs={"pk": self.elts_process.id}), {"element_name_contains": "something"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"__all__": ["Cannot edit a process while it is running"]}) @@ -939,7 +938,6 @@ class TestProcesses(FixtureAPITestCase): response = self.client.patch( reverse("api:process-details", kwargs={"pk": self.elts_process.id}), {"name": "newName"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.elts_process.refresh_from_db() @@ -967,7 +965,6 @@ class TestProcesses(FixtureAPITestCase): response = self.client.patch( reverse("api:process-details", kwargs={"pk": process.id}), {"element_id": str(element.id)}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1006,7 +1003,6 @@ class TestProcesses(FixtureAPITestCase): response = self.client.patch( reverse("api:process-details", kwargs={"pk": self.elts_process.id}), {"state": "stopping"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1026,7 +1022,6 @@ class TestProcesses(FixtureAPITestCase): response = self.client.patch( reverse("api:process-details", kwargs={"pk": self.elts_process.id}), {"state": "stopping"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1050,7 +1045,6 @@ class TestProcesses(FixtureAPITestCase): response = self.client.patch( reverse("api:process-details", kwargs={"pk": self.elts_process.id}), {"state": state.value}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1078,7 +1072,6 @@ class TestProcesses(FixtureAPITestCase): response = self.client.patch( reverse("api:process-details", kwargs={"pk": self.elts_process.id}), {"state": "stopping"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1117,7 +1110,6 @@ class TestProcesses(FixtureAPITestCase): "element_type": "page", "load_children": True }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( @@ -1144,7 +1136,6 @@ class TestProcesses(FixtureAPITestCase): "load_children": True, "state": "stopping", }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1175,7 +1166,6 @@ class TestProcesses(FixtureAPITestCase): "load_children": True, "state": state.value, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1210,7 +1200,6 @@ class TestProcesses(FixtureAPITestCase): "load_children": True, "state": "stopping", }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1244,7 +1233,6 @@ class TestProcesses(FixtureAPITestCase): "load_children": True, "template_id": None, }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1277,7 +1265,6 @@ class TestProcesses(FixtureAPITestCase): "load_children": True, "template_id": None, }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -1316,7 +1303,6 @@ class TestProcesses(FixtureAPITestCase): "started": "2038-01-19T03:14:08Z", "finished": "2038-01-19T03:14:08Z", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1369,7 +1355,6 @@ class TestProcesses(FixtureAPITestCase): response = self.client.patch( reverse("api:process-details", kwargs={"pk": process.id}), {"element_name_contains": "something"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( @@ -1402,7 +1387,6 @@ class TestProcesses(FixtureAPITestCase): { "name": "newName" }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) process.refresh_from_db() @@ -1442,7 +1426,6 @@ class TestProcesses(FixtureAPITestCase): "ml_class_id": str(self.ml_class.id), "load_children": True, }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1472,7 +1455,6 @@ class TestProcesses(FixtureAPITestCase): "element_type": None, "load_children": False }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) process.refresh_from_db() @@ -1487,7 +1469,6 @@ class TestProcesses(FixtureAPITestCase): response = self.client.patch( reverse("api:process-details", kwargs={"pk": process.id}), {"element_type": "unexisting_type"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual( @@ -1512,7 +1493,6 @@ class TestProcesses(FixtureAPITestCase): { "ml_class_id": str(ml_class_id), }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -1550,7 +1530,6 @@ class TestProcesses(FixtureAPITestCase): "started": "2038-01-19T03:14:08Z", "finished": "2038-01-19T03:14:08Z", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1827,7 +1806,7 @@ class TestProcesses(FixtureAPITestCase): "files": [str(self.img_df.id)], "folder_type": "volume", "element_type": "page", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) def test_from_files(self): @@ -1842,7 +1821,7 @@ class TestProcesses(FixtureAPITestCase): "files": [str(self.img_df.id)], "folder_type": "volume", "element_type": "page", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -1867,7 +1846,7 @@ class TestProcesses(FixtureAPITestCase): "files": [str(self.pdf_df.id)], "folder_type": "volume", "element_type": "page", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() process = Process.objects.get(id=data["id"]) @@ -1884,7 +1863,7 @@ class TestProcesses(FixtureAPITestCase): "files": [str(self.iiif_df.id)], "folder_type": "volume", "element_type": "page", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -1918,7 +1897,7 @@ class TestProcesses(FixtureAPITestCase): "mode": "files", "folder_type": "volume", "element_type": "page", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -1943,7 +1922,7 @@ class TestProcesses(FixtureAPITestCase): "files": [str(self.bad_df.id)], "folder_type": "volume", "element_type": "page", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), {"non_field_errors": ["File imports can only import images, PDF documents, ZIP archives or IIIF manifests"]}) @@ -1958,7 +1937,7 @@ class TestProcesses(FixtureAPITestCase): "folder_type": "volume", "element_type": "page", "mode": "easy" - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() process = Process.objects.get(id=data["id"]) @@ -1978,7 +1957,6 @@ class TestProcesses(FixtureAPITestCase): "folder_type": "volume", "element_type": "page", }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -1997,7 +1975,6 @@ class TestProcesses(FixtureAPITestCase): "folder_id": str(volume.id), "element_type": "page", }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"folder_type": ["This field is required."]}) @@ -2008,7 +1985,7 @@ class TestProcesses(FixtureAPITestCase): "files": [], "folder_type": "volume", "element_type": "page", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) def test_from_files_farm(self): @@ -2025,7 +2002,7 @@ class TestProcesses(FixtureAPITestCase): "folder_type": "volume", "element_type": "page", "farm_id": str(farm.id), - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -2047,7 +2024,7 @@ class TestProcesses(FixtureAPITestCase): "files": [str(self.img_df.id)], "folder_type": "volume", "element_type": "page", - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -2068,7 +2045,7 @@ class TestProcesses(FixtureAPITestCase): "folder_type": "volume", "element_type": "page", "farm_id": str(Farm.objects.first().id), - }, format="json") + }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), { diff --git a/arkindex/process/tests/test_templates.py b/arkindex/process/tests/test_templates.py index 0857e6d34a44fd0610ea737378ba87385dd78e85..98cf6a78a31706176375899b952edd489ba44d45 100644 --- a/arkindex/process/tests/test_templates.py +++ b/arkindex/process/tests/test_templates.py @@ -271,7 +271,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.post( reverse("api:create-process-template", kwargs={"pk": str(self.template.id)}), data={"process_id": str(self.process.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -287,7 +286,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.post( reverse("api:create-process-template", kwargs={"pk": str(self.template.id)}), data={"process_id": str(local_process.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -305,7 +303,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.post( reverse("api:apply-process-template", kwargs={"pk": str(self.private_template.id)}), data={"process_id": str(self.process.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -326,7 +323,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.post( reverse("api:apply-process-template", kwargs={"pk": str(self.private_template.id)}), data={"process_id": str(self.process.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -351,7 +347,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.post( reverse("api:apply-process-template", kwargs={"pk": str(self.private_template.id)}), data={"process_id": str(self.process.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -374,7 +369,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.post( reverse("api:apply-process-template", kwargs={"pk": str(self.template.id)}), data={"process_id": str(process_with_template.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( @@ -390,7 +384,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.post( reverse("api:apply-process-template", kwargs={"pk": str(self.process.id)}), data={"process_id": str(self.process.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) @@ -401,7 +394,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.post( reverse("api:apply-process-template", kwargs={"pk": str(self.template.id)}), data={"process_id": str(self.process.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.json()["template_id"], str(self.template.id)) @@ -433,7 +425,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.post( reverse("api:apply-process-template", kwargs={"pk": str(self.template.id)}), data={"process_id": str(self.process.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -480,7 +471,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.post( reverse("api:apply-process-template", kwargs={"pk": str(self.template.id)}), data={"process_id": str(process.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.json()["template_id"], str(self.template.id)) @@ -556,7 +546,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.post( reverse("api:apply-process-template", kwargs={"pk": str(self.template.id)}), data={"process_id": str(self.process.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"non_field_errors": ["This template contains one or more unavailable worker versions and cannot be applied."]}) @@ -571,7 +560,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.post( reverse("api:apply-process-template", kwargs={"pk": str(self.template.id)}), data={"process_id": str(self.process.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"non_field_errors": ["This template contains one or more worker versions from archived workers and cannot be applied."]}) @@ -587,7 +575,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.post( reverse("api:apply-process-template", kwargs={"pk": str(self.template.id)}), data={"process_id": str(self.process.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -605,7 +592,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.post( reverse("api:apply-process-template", kwargs={"pk": str(self.template.id)}), data={"process_id": str(self.process.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -624,7 +610,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.post( reverse("api:apply-process-template", kwargs={"pk": str(self.template.id)}), data={"process_id": str(self.process.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -642,7 +627,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.post( reverse("api:apply-process-template", kwargs={"pk": str(self.template.id)}), data={"process_id": str(local_process.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -658,7 +642,6 @@ class TestTemplates(FixtureAPITestCase): response = self.client.get( reverse("api:process-list"), data={"mode": "template", "with_tasks": True}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) # The 'with_tasks' filter should be ignored and some templates should be returned diff --git a/arkindex/process/tests/test_worker_configurations.py b/arkindex/process/tests/test_worker_configurations.py index e80b58dc7b29b2c728c2f95d287fa055756c8055..4c16a653a2bd1899073a71cb591776b9ee62b85a 100644 --- a/arkindex/process/tests/test_worker_configurations.py +++ b/arkindex/process/tests/test_worker_configurations.py @@ -140,7 +140,6 @@ class TestWorkerConfigurations(FixtureAPITestCase): response = self.client.post( reverse("api:worker-configurations", kwargs={"pk": str(self.worker_2.id)}), data={"name": name, "configuration": {"key": "value", "cahuete": "bidule"}}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( @@ -158,7 +157,6 @@ class TestWorkerConfigurations(FixtureAPITestCase): response = self.client.post( reverse("api:worker-configurations", kwargs={"pk": str(self.worker_2.id)}), data={"name": "New configuration", "configuration": config}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( @@ -178,7 +176,6 @@ class TestWorkerConfigurations(FixtureAPITestCase): response = self.client.post( reverse("api:worker-configurations", kwargs={"pk": str(self.worker_2.id)}), data={"name": "a config name", "configuration": config}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( @@ -201,7 +198,6 @@ class TestWorkerConfigurations(FixtureAPITestCase): response = self.client.post( reverse("api:worker-configurations", kwargs={"pk": str(self.worker_2.id)}), data={"name": "a config name", "configuration": config_2}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual( @@ -227,7 +223,6 @@ class TestWorkerConfigurations(FixtureAPITestCase): response = self.client.post( reverse("api:worker-configurations", kwargs={"pk": str(self.worker_2.id)}), data={"name": name, "configuration": config}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) configuration = self.worker_2.configurations.get(name=name) @@ -248,7 +243,6 @@ class TestWorkerConfigurations(FixtureAPITestCase): response = self.client.post( reverse("api:worker-configurations", kwargs={"pk": str(self.worker_2.id)}), data={"name": name}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), {"configuration": ["This field is required."]}) @@ -258,7 +252,7 @@ class TestWorkerConfigurations(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.post( reverse("api:worker-configurations", kwargs={"pk": str(self.worker_1.id)}), - data={"name": "test_config", "configuration": []}, format="json" + data={"name": "test_config", "configuration": []}, ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -270,7 +264,7 @@ class TestWorkerConfigurations(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.post( reverse("api:worker-configurations", kwargs={"pk": str(self.worker_1.id)}), - data={"name": "test_config", "configuration": None}, format="json" + {"name": "test_config", "configuration": None}, ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -282,7 +276,7 @@ class TestWorkerConfigurations(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.post( reverse("api:worker-configurations", kwargs={"pk": str(self.worker_1.id)}), - data={"name": "test_config", "configuration": {}}, format="json" + {"name": "test_config", "configuration": {}}, ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -412,7 +406,6 @@ class TestWorkerConfigurations(FixtureAPITestCase): "configuration": {"stop": "hammertime"}, "archived": True, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -438,7 +431,6 @@ class TestWorkerConfigurations(FixtureAPITestCase): "name": "new name", "archived": True, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -466,7 +458,6 @@ class TestWorkerConfigurations(FixtureAPITestCase): "name": "new name", "archived": False, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -489,7 +480,6 @@ class TestWorkerConfigurations(FixtureAPITestCase): "name": "new name", "archived": False, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -576,7 +566,6 @@ class TestWorkerConfigurations(FixtureAPITestCase): "configuration": {"stop": "hammertime"}, "archived": True, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -601,7 +590,6 @@ class TestWorkerConfigurations(FixtureAPITestCase): data={ "name": "new name", }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -627,7 +615,6 @@ class TestWorkerConfigurations(FixtureAPITestCase): data={ "name": "new name", }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) diff --git a/arkindex/process/tests/test_workerruns.py b/arkindex/process/tests/test_workerruns.py index a6c4579c038c9a09d781d74d80f97044b7d25e10..40ad68fcdeb66fe6477998646c1e3d51ad717598 100644 --- a/arkindex/process/tests/test_workerruns.py +++ b/arkindex/process/tests/test_workerruns.py @@ -183,7 +183,6 @@ class TestWorkerRuns(FixtureAPITestCase): response = self.client.post( reverse("api:worker-run-list", kwargs={"pk": str(self.process_2.id)}), data={"worker_version_id": str(self.version_1.id), "parents": []}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -201,7 +200,6 @@ class TestWorkerRuns(FixtureAPITestCase): response = self.client.post( reverse("api:worker-run-list", kwargs={"pk": str(self.process_2.id)}), data={"worker_version_id": str(self.version_1.id), "parents": []}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -219,7 +217,6 @@ class TestWorkerRuns(FixtureAPITestCase): response = self.client.post( reverse("api:worker-run-list", kwargs={"pk": str(self.process_2.id)}), data={"worker_version_id": version_id}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -254,7 +251,6 @@ class TestWorkerRuns(FixtureAPITestCase): "model_version_id": str(model_version.id) if model_version else None, "configuration_id": str(configuration.id) if configuration else None, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -271,7 +267,6 @@ class TestWorkerRuns(FixtureAPITestCase): response = self.client.post( reverse("api:worker-run-list", kwargs={"pk": str(self.process_2.id)}), data={"worker_version_id": str(self.version_1.id), "parents": []}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -286,7 +281,6 @@ class TestWorkerRuns(FixtureAPITestCase): response = self.client.post( reverse("api:worker-run-list", kwargs={"pk": str(self.process_2.id)}), data={"worker_version_id": str(self.version_1.id), "parents": []}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -303,7 +297,6 @@ class TestWorkerRuns(FixtureAPITestCase): response = self.client.post( reverse("api:worker-run-list", kwargs={"pk": str(self.process_2.id)}), data={"worker_version_id": str(self.version_1.id), "model_version_id": str(self.model_version_1.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -316,7 +309,6 @@ class TestWorkerRuns(FixtureAPITestCase): response = self.client.post( reverse("api:worker-run-list", kwargs={"pk": uuid.uuid4()}), data={"worker_version_id": str(self.version_1.id), "parents": []}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) @@ -334,7 +326,6 @@ class TestWorkerRuns(FixtureAPITestCase): response = self.client.post( reverse("api:worker-run-list", kwargs={"pk": str(self.process_2.id)}), {"worker_version_id": str(self.version_1.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -349,7 +340,6 @@ class TestWorkerRuns(FixtureAPITestCase): response = self.client.post( reverse("api:worker-run-list", kwargs={"pk": str(process.id)}), {"worker_version_id": str(self.version_1.id), "parents": []}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) @@ -367,7 +357,6 @@ class TestWorkerRuns(FixtureAPITestCase): response = self.client.post( reverse("api:worker-run-list", kwargs={"pk": str(process.id)}), data={"worker_version_id": str(self.version_1.id), "parents": []}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -389,7 +378,6 @@ class TestWorkerRuns(FixtureAPITestCase): response = self.client.post( reverse("api:worker-run-list", kwargs={"pk": str(self.process_2.id)}), {"worker_version_id": str(self.version_1.id), "parents": []}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -465,7 +453,6 @@ class TestWorkerRuns(FixtureAPITestCase): "parents": [], "configuration_id": str(self.configuration_1.id) }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -526,7 +513,6 @@ class TestWorkerRuns(FixtureAPITestCase): response = self.client.post( reverse("api:worker-run-list", kwargs={"pk": str(self.process_2.id)}), data={"worker_version_id": str(self.version_1.id), "parents": [], "configuration_id": str(self.configuration_2.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -587,7 +573,6 @@ class TestWorkerRuns(FixtureAPITestCase): response = self.client.post( reverse("api:worker-run-list", kwargs={"pk": str(self.process_2.id)}), data=payload, - format="json", ) if response.status_code == 400: self.assertDictEqual(response.json(), {}) @@ -956,7 +941,6 @@ class TestWorkerRuns(FixtureAPITestCase): response = self.client.put( reverse("api:worker-run-details", kwargs={"pk": str(self.run_1.id)}), data={}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -977,7 +961,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "parents": [str(run_2.id)], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -1041,7 +1024,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "parents": [str(run_2.id)], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) @@ -1054,7 +1036,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "parents": ["12341234-1234-1234-1234-123412341234"], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1077,7 +1058,6 @@ class TestWorkerRuns(FixtureAPITestCase): str(run_2.id), ], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1111,7 +1091,6 @@ class TestWorkerRuns(FixtureAPITestCase): "process_id": str(self.process_2.id), "parents": [], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1173,7 +1152,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "worker_version_id": str(self.version_2.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1236,7 +1214,6 @@ class TestWorkerRuns(FixtureAPITestCase): "parents": [], "configuration_id": str(self.configuration_1.id) }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1302,7 +1279,6 @@ class TestWorkerRuns(FixtureAPITestCase): response = self.client.put( reverse("api:worker-run-details", kwargs={"pk": self.run_1.id}), data={"parents": [], "configuration_id": str(self.configuration_2.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1322,7 +1298,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "parents": [], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1353,7 +1328,6 @@ class TestWorkerRuns(FixtureAPITestCase): "model_version_id": str(self.model_version_1.id), "parents": [] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1385,7 +1359,6 @@ class TestWorkerRuns(FixtureAPITestCase): "model_version_id": random_model_version_uuid, "parents": [] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1427,7 +1400,6 @@ class TestWorkerRuns(FixtureAPITestCase): "model_version_id": str(model_version_no_access.id), "parents": [] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1498,7 +1470,6 @@ class TestWorkerRuns(FixtureAPITestCase): "model_version_id": str(model_version.id), "parents": [], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1533,7 +1504,6 @@ class TestWorkerRuns(FixtureAPITestCase): "model_version_id": str(self.model_version_1.id), "parents": [] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1559,7 +1529,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "model_version_id": str(self.model_version_1.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1603,7 +1572,6 @@ class TestWorkerRuns(FixtureAPITestCase): "model_version_id": str(model_version.id), "parents": [], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1692,7 +1660,6 @@ class TestWorkerRuns(FixtureAPITestCase): "configuration_id": str(self.configuration_1.id), "parents": [] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1777,7 +1744,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "parents": [str(run_2.id)], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1863,7 +1829,6 @@ class TestWorkerRuns(FixtureAPITestCase): "model_version_id": str(model_version.id) if model_version else None, "configuration_id": str(configuration.id) if configuration else None, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1905,7 +1870,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "parents": [str(run_2.id)], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -1946,7 +1910,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "parents": [str(run_2.id)], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) @@ -1978,7 +1941,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "parents": ["12341234-1234-1234-1234-123412341234"], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -2000,7 +1962,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "process_id": str(self.process_2.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -2062,7 +2023,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "worker_version_id": str(self.version_2.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -2123,7 +2083,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "configuration_id": str(self.configuration_1.id) }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -2187,7 +2146,6 @@ class TestWorkerRuns(FixtureAPITestCase): response = self.client.patch( reverse("api:worker-run-details", kwargs={"pk": self.run_1.id}), data={"configuration_id": str(self.configuration_2.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -2207,7 +2165,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "parents": [], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -2237,7 +2194,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "model_version_id": str(self.model_version_1.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -2268,7 +2224,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "model_version_id": random_model_version_uuid, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -2303,7 +2258,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "model_version_id": str(model_version_no_access.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -2373,7 +2327,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "model_version_id": str(model_version.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -2408,7 +2361,6 @@ class TestWorkerRuns(FixtureAPITestCase): "model_version_id": str(self.model_version_1.id), "parents": [] }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -2434,7 +2386,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "model_version_id": str(self.model_version_1.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -2476,7 +2427,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "model_version_id": str(model_version.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -2562,7 +2512,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "model_version_id": str(self.model_version_1.id), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -2646,7 +2595,6 @@ class TestWorkerRuns(FixtureAPITestCase): data={ "parents": [str(run_2.id)], }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -2732,7 +2680,6 @@ class TestWorkerRuns(FixtureAPITestCase): "model_version_id": str(model_version.id) if model_version else None, "configuration_id": str(configuration.id) if configuration else None, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) diff --git a/arkindex/process/tests/test_workerruns_use_gpu.py b/arkindex/process/tests/test_workerruns_use_gpu.py index ef1bcb1aea32486c8cf48918cda3aa187f8bfb41..79704d3cf80653b5210d34b9c889286eb76a8c54 100644 --- a/arkindex/process/tests/test_workerruns_use_gpu.py +++ b/arkindex/process/tests/test_workerruns_use_gpu.py @@ -63,7 +63,6 @@ class TestWorkerRunsGPU(FixtureAPITestCase): response = self.client.post( reverse("api:worker-run-list", kwargs={"pk": str(self.test_process.id)}), {"worker_version_id": str(worker_version.id), "parents": []}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -119,7 +118,6 @@ class TestWorkerRunsGPU(FixtureAPITestCase): response = self.client.post( reverse("api:worker-run-list", kwargs={"pk": str(self.test_process.id)}), {"worker_version_id": str(self.version_gpu_required.id), "parents": [], "use_gpu": False}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) diff --git a/arkindex/process/tests/test_workers.py b/arkindex/process/tests/test_workers.py index 923724c89751ad8c18edf03369d699ad45feca7a..17406155d9a1714890b1d0c822e4f6eb9da03642 100644 --- a/arkindex/process/tests/test_workers.py +++ b/arkindex/process/tests/test_workers.py @@ -1192,7 +1192,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): response = self.client.post( reverse("api:worker-versions", kwargs={"pk": "12341234-1234-1234-1234-123412341234"}), data={"configuration": {"test": "test2"}}, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) @@ -1208,7 +1207,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): "state": "available", }, HTTP_AUTHORIZATION=f"Ponos {self.task.token}", - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1228,7 +1226,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): "state": "available", }, HTTP_AUTHORIZATION=f"Ponos {self.task.token}", - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1259,7 +1256,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): "configuration": {}, "revision_url": "https://gitlab.com/NERV/eva/commit/eva-01" }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1277,7 +1273,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): response = self.client.post( reverse("api:worker-versions", kwargs={"pk": str(self.worker_reco.id)}), data={"configuration": {"test": "test2"}, "model_usage": FeatureUsage.Required.value}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1293,7 +1288,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): response = self.client.post( reverse("api:worker-versions", kwargs={"pk": str(self.worker_custom.id)}), data={"configuration": {"test": "test2"}, "model_usage": FeatureUsage.Required.value}, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1310,7 +1304,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): response = self.client.post( reverse("api:worker-versions", kwargs={"pk": str(self.worker_custom.id)}), data={"configuration": {"test": "val"}, "model_usage": FeatureUsage.Required.value}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -1328,7 +1321,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): response = self.client.post( reverse("api:worker-versions", kwargs={"pk": str(self.worker_dla.id)}), data={"revision_url": "https://gitlab.com/NERV/eva/commit/eva-01", "configuration": {"test": "test2"}, "model_usage": FeatureUsage.Required.value}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1367,7 +1359,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): response = self.client.post( reverse("api:worker-versions", kwargs={"pk": str(self.worker_custom.id)}), data={"configuration": {"test": "val"}, "model_usage": FeatureUsage.Required.value}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -1403,7 +1394,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): response = self.client.post( reverse("api:worker-versions", kwargs={"pk": str(self.worker_reco.id)}), data={"configuration": "test"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), {"configuration": ['Expected a dictionary of items but got type "str".']}) @@ -1416,7 +1406,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): "model_usage": FeatureUsage.Required.value, "revision_url": "https://gitlab.com/NERV/eva/commit/eva-01", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1440,7 +1429,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): "configuration": {"test": "test2"}, "revision_url": "https://gitlab.com/NERV/eva/commit/eva-01", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1456,7 +1444,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): "revision_url": "https://gitlab.com/NERV/eva/commit/eva-01", "tag": "eva-01", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1479,7 +1466,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): response = self.client.post( reverse("api:worker-versions", kwargs={"pk": str(self.worker_reco.id)}), data={"configuration": {"test": "test2"}, "revision_url": "https://gitlab.com/NERV/eva/commit/eva-01", "tag": "eva-01"}, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1490,7 +1476,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): response = self.client.post( reverse("api:worker-versions", kwargs={"pk": str(self.worker_reco.id)}), data={"configuration": {"test": "test2"}, "revision_url": "https://gitlab.com/NERV/eva/commit/eva-01", "tag": ""}, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1500,7 +1485,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): response = self.client.post( reverse("api:worker-versions", kwargs={"pk": str(self.worker_reco.id)}), data={"configuration": {"test": "test2"}, "revision_url": "https://gitlab.com/NERV/eva/commit/eva-01", "gpu_usage": "not_supported"}, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1513,7 +1497,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): "revision_url": "https://gitlab.com/NERV/eva/commit/eva-01", "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1531,7 +1514,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): "gpu_usage": "disabled", "revision_url": "https://gitlab.com/NERV/eva/commit/eva-01", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1564,7 +1546,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): "revision_url": "https://gitlab.com/NERV/eva/commit/eva-01", "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1590,7 +1571,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): }, "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1607,7 +1587,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): "revision_url": "https://gitlab.com/NERV/eva/commit/eva-01", "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1636,7 +1615,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): "revision_url": "https://gitlab.com/NERV/eva/commit/eva-01", "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1672,7 +1650,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): "revision_url": "https://gitlab.com/NERV/eva/commit/eva-01", "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1702,7 +1679,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): }, "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1727,7 +1703,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): }, "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1752,7 +1727,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): }, "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1777,7 +1751,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): }, "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1802,7 +1775,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): }, "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1825,7 +1797,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): }, "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1842,7 +1813,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): }, "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1868,7 +1838,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): }, "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1899,7 +1868,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): }, "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1929,7 +1897,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): }, "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1954,7 +1921,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): }, "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1988,7 +1954,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): }, "gpu_usage": "disabled", }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -2028,7 +1993,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): } }, }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -2044,7 +2008,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): } }, }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -2126,7 +2089,7 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): "state": "error", "gpu_usage": "disabled", "model_usage": FeatureUsage.Disabled.value, - }, format="json" + }, ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertEqual(response.json(), {"detail": "Authentication credentials were not provided."}) @@ -2141,7 +2104,7 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): "state": "error", "gpu_usage": "disabled", "model_usage": FeatureUsage.Disabled.value, - }, format="json" + }, ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) @@ -2162,7 +2125,7 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): "state": "error", "gpu_usage": "disabled", "model_usage": FeatureUsage.Disabled.value, - }, format="json" + }, ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertEqual(response.json(), {"detail": "Only Ponos tasks are allowed to update a worker version."}) @@ -2182,7 +2145,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): "state": "error", "tag": "eva-01" }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -2209,7 +2171,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): data={ "tag": "eva-01" }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -2222,7 +2183,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): data={ "tag": "" }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -2239,7 +2199,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): data={ "revision_url": "updated" }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -2256,7 +2215,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): data={ "revision_url": "https://gitlab.com/NERV/eva/commit/eva-01" }, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) # revision_url just gets ignored @@ -2274,7 +2232,6 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): response = self.client.patch( reverse("api:version-retrieve", kwargs={"pk": str(self.version_1.id)}), data={"state": "available"}, - format="json", HTTP_AUTHORIZATION=f"Ponos {self.task.token}", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) diff --git a/arkindex/project/settings.py b/arkindex/project/settings.py index 90b3339d2fb6ce35e5349e88f4f3a5a2ef429ac4..ecb16e5f48ea216a27d5cfd2ec12d3742e102b19 100644 --- a/arkindex/project/settings.py +++ b/arkindex/project/settings.py @@ -209,6 +209,7 @@ REST_FRAMEWORK = { "DEFAULT_PAGINATION_CLASS": "arkindex.project.pagination.PageNumberPagination", "DEFAULT_SCHEMA_CLASS": "arkindex.project.openapi.AutoSchema", "PAGE_SIZE": 20, + "TEST_REQUEST_DEFAULT_FORMAT": "json", } SIMPLE_JWT = { diff --git a/arkindex/training/tests/test_dataset_sets_api.py b/arkindex/training/tests/test_dataset_sets_api.py index cafedafb83aba56654d34b3a7e5d6b835d8aec2b..74a756dd96bf32ea03eab12c60bd865362491a33 100644 --- a/arkindex/training/tests/test_dataset_sets_api.py +++ b/arkindex/training/tests/test_dataset_sets_api.py @@ -40,7 +40,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-sets", kwargs={"pk": self.dataset.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "Authentication credentials were not provided."}) @@ -52,7 +51,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-sets", kwargs={"pk": self.dataset.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "You do not have permission to perform this action."}) @@ -63,7 +61,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-sets", kwargs={"pk": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertDictEqual(response.json(), {"detail": "No Dataset matches the given query."}) @@ -76,7 +73,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-sets", kwargs={"pk": str(self.private_dataset.pk)}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertDictEqual(response.json(), {"detail": "No Dataset matches the given query."}) @@ -93,7 +89,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-sets", kwargs={"pk": self.private_dataset.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -114,7 +109,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-sets", kwargs={"pk": self.dataset.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -127,7 +121,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-sets", kwargs={"pk": self.dataset.pk}), data={"name": "train"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -140,7 +133,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-sets", kwargs={"pk": self.dataset.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -157,7 +149,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.put( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "Authentication credentials were not provided."}) @@ -169,7 +160,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.put( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "You do not have permission to perform this action."}) @@ -180,7 +170,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.put( reverse("api:dataset-set", kwargs={"dataset": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "set": self.train_set.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertDictEqual(response.json(), {"detail": "No Dataset matches the given query."}) @@ -191,7 +180,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.put( reverse("api:dataset-set", kwargs={"dataset": self.dataset.id, "set": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertDictEqual(response.json(), {"detail": "No DatasetSet matches the given query."}) @@ -204,7 +192,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.put( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertDictEqual(response.json(), {"detail": "No Dataset matches the given query."}) @@ -221,7 +208,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.put( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -242,7 +228,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.put( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -255,7 +240,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.put( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), data={"name": "dev"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -268,7 +252,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.put( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -286,7 +269,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "Authentication credentials were not provided."}) @@ -298,7 +280,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "You do not have permission to perform this action."}) @@ -309,7 +290,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:dataset-set", kwargs={"dataset": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "set": self.train_set.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertDictEqual(response.json(), {"detail": "No Dataset matches the given query."}) @@ -320,7 +300,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:dataset-set", kwargs={"dataset": self.dataset.id, "set": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertDictEqual(response.json(), {"detail": "No DatasetSet matches the given query."}) @@ -333,7 +312,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertDictEqual(response.json(), {"detail": "No Dataset matches the given query."}) @@ -350,7 +328,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -371,7 +348,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -384,7 +360,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), data={"name": "dev"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -397,7 +372,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), data={"name": "Unit-00"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -414,7 +388,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): with self.assertNumQueries(0): response = self.client.delete( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "Authentication credentials were not provided."}) @@ -425,7 +398,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): with self.assertNumQueries(2): response = self.client.delete( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "You do not have permission to perform this action."}) @@ -435,7 +407,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.delete( reverse("api:dataset-set", kwargs={"dataset": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "set": self.train_set.pk}), - format="json" ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertDictEqual(response.json(), {"detail": "No Dataset matches the given query."}) @@ -445,7 +416,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): with self.assertNumQueries(6): response = self.client.delete( reverse("api:dataset-set", kwargs={"dataset": self.dataset.id, "set": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}), - format="json" ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertDictEqual(response.json(), {"detail": "No DatasetSet matches the given query."}) @@ -457,7 +427,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): with self.assertNumQueries(3): response = self.client.delete( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), - format="json" ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertDictEqual(response.json(), {"detail": "No Dataset matches the given query."}) @@ -476,7 +445,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.delete( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -496,7 +464,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): with self.assertNumQueries(5): response = self.client.delete( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -508,7 +475,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): with self.assertNumQueries(7): response = self.client.delete( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), ["This dataset set is selected in a process and cannot be deleted."]) @@ -524,7 +490,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): with self.assertNumQueries(7): response = self.client.delete( reverse("api:dataset-set", kwargs={"dataset": test_dataset.pk, "set": test_set.pk}), - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), ["This dataset set is the only one in its dataset and cannot be deleted."]) @@ -539,7 +504,6 @@ class TestDatasetSetsAPI(FixtureAPITestCase): with self.assertNumQueries(9): response = self.client.delete( reverse("api:dataset-set", kwargs={"dataset": self.dataset.pk, "set": self.train_set.pk}), - format="json" ) self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) diff --git a/arkindex/training/tests/test_datasets_api.py b/arkindex/training/tests/test_datasets_api.py index 366166fa9bc1dde4524a017902844ab24ea47cdb..705e1d3a04ef85f434318a614c71a5db14850209 100644 --- a/arkindex/training/tests/test_datasets_api.py +++ b/arkindex/training/tests/test_datasets_api.py @@ -133,7 +133,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-datasets", kwargs={"pk": self.corpus.pk}), data={"name": "My dataset", "description": "My dataset for my experiments."}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "Authentication credentials were not provided."}) @@ -145,7 +144,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-datasets", kwargs={"pk": self.corpus.pk}), data={"name": "My dataset", "description": "My dataset for my experiments."}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "You do not have permission to perform this action."}) @@ -156,7 +154,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-datasets", kwargs={"pk": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}), data={"name": "My dataset", "description": "My dataset for my experiments."}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertDictEqual(response.json(), {"detail": "No Corpus matches the given query."}) @@ -168,7 +165,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-datasets", kwargs={"pk": self.private_corpus.pk}), data={"name": "My dataset", "description": "My dataset for my experiments."}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -183,7 +179,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-datasets", kwargs={"pk": self.corpus.pk}), data={"description": "My dataset for my experiments."}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"name": ["This field is required."]}) @@ -194,7 +189,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-datasets", kwargs={"pk": self.corpus.pk}), data={"name": "", "description": "My dataset for my experiments."}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"name": ["This field may not be blank."]}) @@ -205,7 +199,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-datasets", kwargs={"pk": self.corpus.pk}), data={"name": " ", "description": "My dataset for my experiments."}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"name": ["This field may not be blank."]}) @@ -219,7 +212,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "name": "In elementum leo et lectus finibus, eget lobortis ligula posuere. Vivamus finibus quis sapien in mattis. Cras in libero.", "description": "My dataset for my experiments." }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"name": ["Ensure this field has no more than 100 characters."]}) @@ -233,7 +225,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "name": "First Dataset", "description": "My dataset for my experiments." }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"non_field_errors": ["A dataset with this name already exists in this corpus."]}) @@ -244,7 +235,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-datasets", kwargs={"pk": self.corpus.pk}), data={"name": "My dataset"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"description": ["This field is required."]}) @@ -255,7 +245,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-datasets", kwargs={"pk": self.corpus.pk}), data={"name": "My dataset", "description": ""}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"description": ["This field may not be blank."]}) @@ -266,7 +255,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-datasets", kwargs={"pk": self.corpus.pk}), data={"name": "My dataset", "description": " "}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"description": ["This field may not be blank."]}) @@ -277,7 +265,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-datasets", kwargs={"pk": self.corpus.pk}), data={"name": "My dataset", "description": "My dataset for my experiments.", "unique_elements": False}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) created_dataset = Dataset.objects.get(name="My dataset") @@ -312,7 +299,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-datasets", kwargs={"pk": self.corpus.pk}), data={"name": "My dataset", "description": "My dataset for my experiments.", "state": "complete"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) created_dataset = Dataset.objects.get(name="My dataset") @@ -348,7 +334,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-datasets", kwargs={"pk": self.corpus.pk}), data={"name": "My dataset", "description": "My dataset for my experiments.", "set_names": ["a", "b", "c", "d"]}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) created_dataset = Dataset.objects.get(name="My dataset") @@ -379,7 +364,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-datasets", kwargs={"pk": self.corpus.pk}), data={"name": "My dataset", "description": "My dataset for my experiments.", "set_names": []}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"set_names": ["Either do not specify set names to use the default values, or specify a non-empty list of names."]}) @@ -390,7 +374,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-datasets", kwargs={"pk": self.corpus.pk}), data={"name": "My dataset", "description": "My dataset for my experiments.", "set_names": ["a", "a", "b"]}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"set_names": ["Set names must be unique."]}) @@ -401,7 +384,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:corpus-datasets", kwargs={"pk": self.corpus.pk}), data={"name": "My dataset", "description": "My dataset for my experiments.", "set_names": [" ", " ", "b"]}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -422,7 +404,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "description": "My dataset for my experiments.", "set_names": ["unit-00", "Etiam accumsan ullamcorper mauris eget mattis. Ut porttitor."] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -441,7 +422,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "name": "Shin Seiki Evangelion", "description": "Omedeto!", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "Authentication credentials were not provided."}) @@ -456,7 +436,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "name": "Shin Seiki Evangelion", "description": "Omedeto!", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "You do not have permission to perform this action."}) @@ -471,7 +450,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "name": "Shin Seiki Evangelion", "description": "Omedeto!", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "You do not have contributor access to corpus Unit Tests."}) @@ -488,7 +466,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "name": "Shin Seiki Evangelion", "description": "Omedeto!", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertDictEqual(response.json(), {"detail": "No Dataset matches the given query."}) @@ -502,7 +479,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "name": "In elementum leo et lectus finibus, eget lobortis ligula posuere. Vivamus finibus quis sapien in mattis. Cras in libero.", "description": "My dataset for my experiments.", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"name": ["Ensure this field has no more than 100 characters."]}) @@ -517,7 +493,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "name": "Another Dataset", "description": "My dataset for my experiments.", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"non_field_errors": ["A dataset with this name already exists in this corpus."]}) @@ -528,7 +503,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.put( reverse("api:dataset-update", kwargs={"pk": self.dataset.pk}), data={"name": "Shin Seiki Evangelion"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"description": ["This field is required."]}) @@ -544,7 +518,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "description": "Omedeto!", "set_names": ["unit-01", "unit-02"], }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"set_names": ["This API endpoint does not allow updating a dataset's sets."]}) @@ -558,7 +531,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "name": "", "description": " ", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -576,7 +548,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "description": " ", "set_names": ["unit-00", "unit-00", "unit-02"] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -591,7 +562,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.put( reverse("api:dataset-update", kwargs={"pk": self.dataset.pk}), data={"name": "a", "description": "a", "unique_elements": False}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.dataset.refresh_from_db() @@ -610,7 +580,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.put( reverse("api:dataset-update", kwargs={"pk": self.dataset.pk}), data={"name": "a", "description": "a", "unique_elements": True}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -630,7 +599,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "description": "Omedeto!", "state": "open" }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.dataset.refresh_from_db() @@ -652,7 +620,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "description": "Omedeto!", "state": "complete" }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.dataset.refresh_from_db() @@ -693,7 +660,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "description": self.dataset.description, "state": state_to.value, }, - format="json", ) if expected: self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -723,7 +689,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "description": self.dataset.description, "state": state_to.value, }, - format="json", ) if expected: self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -748,7 +713,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "description": "BB", "unique_elements": False, }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.dataset.refresh_from_db() @@ -767,7 +731,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "description": "Omedeto!", "state": "building" }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -784,7 +747,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "description": "Omedeto!", "state": "decommissioned" }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"state": ["Value is not of type DatasetState"]}) @@ -798,7 +760,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:dataset-update", kwargs={"pk": self.dataset.pk}), data={"name": "Shin Seiki Evangelion"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "Authentication credentials were not provided."}) @@ -810,7 +771,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:dataset-update", kwargs={"pk": self.dataset.pk}), data={"name": "Shin Seiki Evangelion"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "You do not have permission to perform this action."}) @@ -822,7 +782,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:dataset-update", kwargs={"pk": self.dataset.pk}), data={"name": "Shin Seiki Evangelion"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "You do not have contributor access to corpus Unit Tests."}) @@ -838,7 +797,6 @@ class TestDatasetsAPI(FixtureAPITestCase): data={ "name": "In elementum leo et lectus finibus, eget lobortis ligula posuere. Vivamus finibus quis sapien in mattis. Cras in libero.", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"name": ["Ensure this field has no more than 100 characters."]}) @@ -852,7 +810,6 @@ class TestDatasetsAPI(FixtureAPITestCase): data={ "name": "Another Dataset", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"non_field_errors": ["A dataset with this name already exists in this corpus."]}) @@ -863,7 +820,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:dataset-update", kwargs={"pk": self.dataset.pk}), data={"description": "Omedeto!", "unique_elements": False}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.dataset.refresh_from_db() @@ -882,7 +838,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "name": " ", "description": "", }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"name": ["This field may not be blank."], "description": ["This field may not be blank."]}) @@ -898,7 +853,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:dataset-update", kwargs={"pk": self.dataset.pk}), data={"name": "a", "description": "a", "unique_elements": True}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -914,7 +868,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:dataset-update", kwargs={"pk": self.dataset.pk}), data={"state": "open"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.dataset.refresh_from_db() @@ -931,7 +884,6 @@ class TestDatasetsAPI(FixtureAPITestCase): reverse("api:dataset-update", kwargs={"pk": self.dataset.pk}), HTTP_AUTHORIZATION=f"Ponos {self.task.token}", data={"state": "complete"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.dataset.refresh_from_db() @@ -946,7 +898,6 @@ class TestDatasetsAPI(FixtureAPITestCase): reverse("api:dataset-update", kwargs={"pk": self.dataset.pk}), HTTP_AUTHORIZATION=f"Ponos {self.task.token}", data={"state": "building"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -961,7 +912,6 @@ class TestDatasetsAPI(FixtureAPITestCase): data={ "state": "decommissioned" }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"state": ["Value is not of type DatasetState"]}) @@ -1001,7 +951,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "description": self.dataset.description, "state": state_to.value, }, - format="json", ) if expected: self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1027,7 +976,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:dataset-update", kwargs={"pk": self.dataset.pk}), data={"state": state_to.value}, - format="json", ) if expected: self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1052,7 +1000,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "description": "BB", "unique_elements": False, }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.dataset.refresh_from_db() @@ -1578,7 +1525,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-elements", kwargs={"pk": self.dataset.id}), data={"set": "test", "element_id": str(element.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -1591,7 +1537,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-elements", kwargs={"pk": self.dataset.id}), data={"set": "aaaaaaaaaaa", "element_id": str(self.vol.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -1606,7 +1551,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-elements", kwargs={"pk": self.dataset.id}), data={"set": "test", "element_id": str(self.vol.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertListEqual(response.json(), ["You can only add elements to a dataset in an open state."]) @@ -1621,7 +1565,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-elements", kwargs={"pk": self.dataset.id}), data={"set": "test", "element_id": str(self.page1.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"non_field_errors": ["This element is already part of this set."]}) @@ -1633,7 +1576,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-elements", kwargs={"pk": self.dataset.id}), data={"set": "train", "element_id": str(self.page1.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertQuerySetEqual( @@ -1649,7 +1591,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-elements", kwargs={"pk": self.dataset.id}), data={"set": "test", "element_id": str(self.page1.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -1666,7 +1607,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-elements", kwargs={"pk": self.dataset.id}), data={"set": "test", "element_id": str(self.page1.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertQuerySetEqual( @@ -1751,7 +1691,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-elements-selection", kwargs={"pk": self.corpus.id}), data={"set_id": "AAA"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -1765,7 +1704,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-elements-selection", kwargs={"pk": self.corpus.id}), data={"set_id": self.private_dataset_set.id}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -1782,7 +1720,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-elements-selection", kwargs={"pk": self.corpus.id}), data={"set_id": test_set.id}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -1803,7 +1740,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-elements-selection", kwargs={"pk": self.corpus.id}), data={"set_id": str(train_set.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) self.assertQuerySetEqual( @@ -1825,7 +1761,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-elements-selection", kwargs={"pk": self.corpus.id}), data={"set_id": str(test_set.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -1845,7 +1780,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-elements-selection", kwargs={"pk": self.corpus.id}), data={"set_id": str(test_set.id)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) self.assertQuerySetEqual( @@ -2292,7 +2226,6 @@ class TestDatasetsAPI(FixtureAPITestCase): with self.assertNumQueries(14): response = self.client.post( reverse("api:dataset-clone", kwargs={"pk": self.dataset.id}), - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertCountEqual(self.corpus.datasets.values_list("name", flat=True), [ @@ -2351,7 +2284,6 @@ class TestDatasetsAPI(FixtureAPITestCase): with self.assertNumQueries(13): response = self.client.post( reverse("api:dataset-clone", kwargs={"pk": self.dataset.id}), - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertCountEqual(self.corpus.datasets.values_list("name", flat=True), [ @@ -2402,7 +2334,6 @@ class TestDatasetsAPI(FixtureAPITestCase): with self.assertNumQueries(12): response = self.client.post( reverse("api:dataset-clone", kwargs={"pk": dataset.id}), - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -2610,7 +2541,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "count": "d", "sets": "e", }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -2633,7 +2563,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "types": ["page", "A", "AAAAAA"], "sets": {"test": .8, "A": .15, "AAAAA": .05}, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -2648,7 +2577,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-populate", kwargs={"pk": self.dataset.pk}), data={"recursive": True}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -2661,7 +2589,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-populate", kwargs={"pk": self.dataset.pk}), data={"recursive": True, "sets": {"test": 0.13, "train": 0.37}}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -2674,7 +2601,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-populate", kwargs={"pk": self.dataset.pk}), data={"recursive": True, "count": 5, "sets": {"test": 0.01, "train": 0.99}}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -2692,7 +2618,6 @@ class TestDatasetsAPI(FixtureAPITestCase): response = self.client.post( reverse("api:dataset-populate", kwargs={"pk": self.dataset.pk}), data={"recursive": True, "count": 1, "sets": {"test": 1}}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -2713,7 +2638,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "types": ["page", "word"], "count": 11, "sets": {"train": .2, "dev": .7, "test": .1}}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.json(), {}) @@ -2741,7 +2665,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "count": 3, "sets": {"train": 1} }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.json(), {}) @@ -2771,7 +2694,6 @@ class TestDatasetsAPI(FixtureAPITestCase): "count": 12, "sets": {"train": 1} }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertQuerysetEqual( diff --git a/arkindex/training/tests/test_metrics_api.py b/arkindex/training/tests/test_metrics_api.py index a1efc6de3c6b6ceeb0f515a73d59536f4f73ad53..8c52cb0e85c2ef5aaf6714033333102eee81ad14 100644 --- a/arkindex/training/tests/test_metrics_api.py +++ b/arkindex/training/tests/test_metrics_api.py @@ -37,7 +37,6 @@ class TestMetricsAPI(FixtureAPITestCase): "name": "a test metric", "value": 1.2 }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "Authentication credentials were not provided."}) @@ -53,7 +52,6 @@ class TestMetricsAPI(FixtureAPITestCase): "name": "a test metric", "value": 1.2 }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "You do not have permission to perform this action."}) @@ -68,7 +66,6 @@ class TestMetricsAPI(FixtureAPITestCase): "name": "a test metric", "value": 1.2 }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"model_version_id": ['Invalid pk "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" - object does not exist.']}) @@ -84,7 +81,6 @@ class TestMetricsAPI(FixtureAPITestCase): "name": "a test metric", "value": 1.2 }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "You do not have contributor access to this model."}) @@ -105,7 +101,6 @@ class TestMetricsAPI(FixtureAPITestCase): "name": "a test metric", "value": 1.2 }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -129,7 +124,6 @@ class TestMetricsAPI(FixtureAPITestCase): "name": "a test metric", "value": 1.2 }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -158,7 +152,6 @@ class TestMetricsAPI(FixtureAPITestCase): "name": "my_metric", "value": 1.2 }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertDictEqual(response.json(), {"created": "2046-01-01T12:34:56Z", "step": None, "value": 1.2}) @@ -188,7 +181,6 @@ class TestMetricsAPI(FixtureAPITestCase): "value": 1.2, "mode": "point" }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -219,7 +211,6 @@ class TestMetricsAPI(FixtureAPITestCase): "mode": "point", "step": 1 }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"step": ["The step property cannot be set for Point type metrics."]}) @@ -238,7 +229,6 @@ class TestMetricsAPI(FixtureAPITestCase): "value": 1.2, "step": 1 }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"step": ["The step property cannot be set for Point type metrics."]}) @@ -257,7 +247,6 @@ class TestMetricsAPI(FixtureAPITestCase): "value": 1.2, "mode": "series" }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"mode": ["Metric Key a test metric already exists and is of mode Point."]}) @@ -277,7 +266,6 @@ class TestMetricsAPI(FixtureAPITestCase): "name": "a test metric", "value": 1.2 }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"__all__": ["Metric Key a test metric is of mode Point and already has a value."]}) @@ -308,7 +296,6 @@ class TestMetricsAPI(FixtureAPITestCase): "value": 1.2, "step": 2 }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertDictEqual(response.json(), {"created": "2046-01-01T12:34:56Z", "step": 2, "value": 1.2}) @@ -336,7 +323,6 @@ class TestMetricsAPI(FixtureAPITestCase): "value": 1.2, "step": 1 }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"step": ["This metric has already been set for this step."]}) @@ -359,7 +345,6 @@ class TestMetricsAPI(FixtureAPITestCase): "name": "another metric", "value": 1.2, }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"step": ["Cannot add a metric value without a step for metric key another metric because it already has metric values with steps set."]}) @@ -383,7 +368,6 @@ class TestMetricsAPI(FixtureAPITestCase): "value": 1.2, "step": 1 }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"step": ["Cannot add a metric value with step set for metric key another metric because it already has metric values with no step set."]}) @@ -409,7 +393,6 @@ class TestMetricsAPI(FixtureAPITestCase): } ] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "You do not have permission to perform this action."}) @@ -433,7 +416,6 @@ class TestMetricsAPI(FixtureAPITestCase): } ] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"model_version_id": ['Invalid pk "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" - object does not exist.']}) @@ -459,7 +441,6 @@ class TestMetricsAPI(FixtureAPITestCase): } ] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "You do not have contributor access to this model."}) @@ -489,7 +470,6 @@ class TestMetricsAPI(FixtureAPITestCase): } ] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -517,7 +497,6 @@ class TestMetricsAPI(FixtureAPITestCase): } ] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"metrics": {"1": {"__all__": ["Cannot send multiple values at once for the same name (some metric)."]}}}) @@ -548,7 +527,6 @@ class TestMetricsAPI(FixtureAPITestCase): } ] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertDictEqual(response.json(), {"metrics": [{"value": 12.0}, {"value": 3.0}]}) @@ -593,7 +571,6 @@ class TestMetricsAPI(FixtureAPITestCase): } ] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertDictEqual(response.json(), {"metrics": [{"value": 12.0}, {"value": 3.0}]}) @@ -645,7 +622,6 @@ class TestMetricsAPI(FixtureAPITestCase): } ] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertDictEqual(response.json(), {"step": 3, "metrics": [{"value": 12.0}, {"value": 3.0}]}) @@ -694,7 +670,6 @@ class TestMetricsAPI(FixtureAPITestCase): } ] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"metrics": { @@ -722,7 +697,6 @@ class TestMetricsAPI(FixtureAPITestCase): } ] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -750,7 +724,6 @@ class TestMetricsAPI(FixtureAPITestCase): } ] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"metrics": {"0": {"mode": ["Metric Key a test metric already exists and is of mode Point."]}}}) @@ -776,7 +749,6 @@ class TestMetricsAPI(FixtureAPITestCase): } ] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"metrics": {"0": {"step": ["This metric has already been set for this step."]}}}) @@ -820,7 +792,6 @@ class TestMetricsAPI(FixtureAPITestCase): } ] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -863,7 +834,6 @@ class TestMetricsAPI(FixtureAPITestCase): } ] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"metrics": {"0": {"step": ["Cannot add a metric value without a step for metric key another metric because it already has metric values with steps set."]}}}) @@ -891,7 +861,6 @@ class TestMetricsAPI(FixtureAPITestCase): } ] }, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"metrics": {"0": {"step": ["Cannot add a metric value with step set for metric key another metric because it already has metric values with no step set."]}}}) diff --git a/arkindex/training/tests/test_model_api.py b/arkindex/training/tests/test_model_api.py index 6a7fce49213e6e3e970893ff8b96bfb521db26f0..1a4da13d1c60a5146891ee6f74c7e242a0ae6bd5 100644 --- a/arkindex/training/tests/test_model_api.py +++ b/arkindex/training/tests/test_model_api.py @@ -448,7 +448,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.put( reverse("api:model-retrieve", kwargs={"pk": str(self.model1.id)}), {"name": "new name", "description": "test"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -464,7 +463,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.put( reverse("api:model-retrieve", kwargs={"pk": str(self.model1.id)}), {"name": self.model2.name, "description": "", "public": True}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"name": ["A model with this name already exists"]}) @@ -488,7 +486,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.put( reverse("api:model-retrieve", kwargs={"pk": str(self.model1.id)}), {"name": "new name", "description": "test", "archived": new_value}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -514,7 +511,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.put( reverse("api:model-retrieve", kwargs={"pk": str(self.model1.id)}), {"name": "new name", "description": "test", "archived": new_value}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -539,7 +535,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.put( reverse("api:model-retrieve", kwargs={"pk": str(self.model1.id)}), {"name": "new name", "description": "", "public": True}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.model1.refresh_from_db() @@ -586,7 +581,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:model-retrieve", kwargs={"pk": str(self.model1.id)}), {"description": "test"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -603,7 +597,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:model-retrieve", kwargs={"pk": str(self.model1.id)}), {"description": "new desc", "public": True}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.model1.refresh_from_db() @@ -642,7 +635,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:model-retrieve", kwargs={"pk": str(self.model1.id)}), {"archived": new_value}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -668,7 +660,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:model-retrieve", kwargs={"pk": str(self.model1.id)}), {"archived": new_value}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -700,7 +691,6 @@ class TestModelAPI(FixtureAPITestCase): "description": "description", "configuration": {"hello": "this is me"}, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -748,7 +738,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.post( reverse("api:model-versions", kwargs={"pk": str(self.model1.id)}), {}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -783,7 +772,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.post( reverse("api:model-versions", kwargs={"pk": str(self.model1.id)}), {"tag": ""}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -798,7 +786,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.post( reverse("api:model-versions", kwargs={"pk": str(self.model1.id)}), {"tag": "tagged"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -826,7 +813,6 @@ class TestModelAPI(FixtureAPITestCase): "description": "description", "configuration": {"hello": "this is me"}, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -860,7 +846,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.post( reverse("api:model-versions", kwargs={"pk": str(self.model1.id)}), {"tag": self.model_version2.tag}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -887,7 +872,6 @@ class TestModelAPI(FixtureAPITestCase): # self.model_version3 belongs to self.model2 "parent": str(self.model_version3.id) }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) data = response.json() @@ -933,7 +917,6 @@ class TestModelAPI(FixtureAPITestCase): # self.model_version3 belongs to self.model2 "parent": str(self.model_version3.id) }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(filter_rights_mock.call_count, 1) @@ -948,7 +931,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.post( reverse("api:model-versions", kwargs={"pk": str(self.model1.id)}), {"hash": self.model_version5.hash}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1222,7 +1204,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:model-version-retrieve", kwargs={"pk": str(self.model_version1.id)}), request, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1268,7 +1249,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:model-version-retrieve", kwargs={"pk": str(self.model_version3.id)}), request, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK, response.json()) @@ -1305,7 +1285,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:model-version-retrieve", kwargs={"pk": str(self.model_version3.id)}), {"parent": None}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1337,7 +1316,6 @@ class TestModelAPI(FixtureAPITestCase): reverse("api:model-version-retrieve", kwargs={"pk": str(self.model_version3.id)}), # self.model_version3 is a version of self.model2, while self.model_version1 belongs to self.model1 {"parent": str(self.model_version1.id)}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1372,7 +1350,6 @@ class TestModelAPI(FixtureAPITestCase): reverse("api:model-version-retrieve", kwargs={"pk": str(self.model_version3.id)}), # self.model_version3 is a version of self.model2, while self.model_version1 belongs to self.model1 {"parent": str(self.model_version1.id)}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1397,7 +1374,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:model-version-retrieve", kwargs={"pk": str(self.model_version3.id)}), {"hash": self.model_version4.hash}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1420,7 +1396,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:model-version-retrieve", kwargs={"pk": str(self.model_version1.id)}), {"archive_hash": "d" * 32, "hash": "e" * 32, "size": 32, "state": "available"}, - format="json" ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -1444,7 +1419,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:model-version-retrieve", kwargs={"pk": str(self.model_version1.id)}), {"archive_hash": "d" * 32, "hash": "e" * 32, "size": 32, "state": "available"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"size": ["Uploaded file size is 31 bytes, expected 32 bytes"]}) @@ -1467,7 +1441,6 @@ class TestModelAPI(FixtureAPITestCase): response = self.client.patch( reverse("api:model-version-retrieve", kwargs={"pk": str(self.model_version3.id)}), {"archive_hash": "d" * 32, "hash": "e" * 32, "size": 32}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1496,7 +1469,6 @@ class TestModelAPI(FixtureAPITestCase): "description": "other description", "configuration": {"hi": "Who am I?"}, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -1525,7 +1497,6 @@ class TestModelAPI(FixtureAPITestCase): "description": "other description", "configuration": {"hi": "Who am I ?"}, }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) diff --git a/arkindex/users/tests/test_password_reset.py b/arkindex/users/tests/test_password_reset.py index 517dc451803e3edd2535ed372468a567f00f26a9..b432358da92606e855689dd1311337d86fcdb3a0 100644 --- a/arkindex/users/tests/test_password_reset.py +++ b/arkindex/users/tests/test_password_reset.py @@ -14,7 +14,6 @@ class TestPasswordReset(FixtureAPITestCase): resp = self.client.post( reverse("api:password-reset"), data={"email": self.user.email}, - format="json", ) self.assertEqual(resp.status_code, status.HTTP_201_CREATED) self.assertEqual(len(mail.outbox), 1) @@ -28,7 +27,6 @@ class TestPasswordReset(FixtureAPITestCase): resp = self.client.post( reverse("api:password-reset"), data={"email": "nopenopenope@nope.no"}, - format="json", ) self.assertEqual(resp.status_code, status.HTTP_201_CREATED) self.assertEqual(len(mail.outbox), 0) @@ -40,7 +38,6 @@ class TestPasswordReset(FixtureAPITestCase): resp = self.client.post( reverse("api:password-reset"), data={"email": "nope"}, - format="json", ) self.assertEqual(resp.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(len(mail.outbox), 0) @@ -55,7 +52,6 @@ class TestPasswordReset(FixtureAPITestCase): "token": "t0k3n", "password": "S3cr37Pa$$w0rd" }, - format="json", ) self.assertEqual(resp.status_code, status.HTTP_201_CREATED) self.user.refresh_from_db() @@ -73,7 +69,6 @@ class TestPasswordReset(FixtureAPITestCase): "token": "t0k3n", "password": "S3cr37Pa$$w0rd" }, - format="json", ) self.assertEqual(resp.status_code, status.HTTP_400_BAD_REQUEST) self.user.refresh_from_db() @@ -96,7 +91,6 @@ class TestPasswordReset(FixtureAPITestCase): response = self.client.post( reverse("api:password-reset-confirm"), data={"uidb64": urlsafe_base64_encode(str(self.user.id).encode()), "token": "t0k3n", "password": pwd}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), {"password": messages}) diff --git a/arkindex/users/tests/test_registration.py b/arkindex/users/tests/test_registration.py index 17de7a3a798df534b3eb4ed4ab07cbde833e95d1..8c289177aa6d35319c66647861548ce51c8c57f6 100644 --- a/arkindex/users/tests/test_registration.py +++ b/arkindex/users/tests/test_registration.py @@ -30,7 +30,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.put( reverse("api:user-retrieve"), data={"password": "N€wP4$5w0Rd"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -66,7 +65,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.patch( reverse("api:user-retrieve"), data={"password": "N€wP4$5w0Rd"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.user.refresh_from_db() @@ -75,7 +73,6 @@ class TestRegistration(FixtureAPITestCase): # Ensure client session is still valid response = self.client.get( reverse("api:user-retrieve"), - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -84,7 +81,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.patch( reverse("api:user-retrieve"), data={"password": "email"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -100,7 +96,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.patch( reverse("api:user-retrieve"), data={"display_name": "There was a typo in my name"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.user.refresh_from_db() @@ -116,7 +111,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.post( reverse("api:user-login"), data={"email": "lol@lol.lol", "password": "password"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "Incorrect authentication credentials."}) @@ -126,7 +120,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.post( reverse("api:user-login"), data={"email": "email@address.com", "password": "wrongpassword"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertDictEqual(response.json(), {"detail": "Incorrect authentication credentials."}) @@ -139,7 +132,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.post( reverse("api:user-login"), data={"email": "eMaIL@adDreSs.cOm", "password": "P4$5w0Rd"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertTrue(auth.get_user(self.client).is_authenticated) @@ -149,7 +141,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.post( reverse("api:user-login"), data={"email": "email@address.com", "password": "P4$5w0Rd"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertTrue(auth.get_user(self.client).is_authenticated) @@ -168,7 +159,6 @@ class TestRegistration(FixtureAPITestCase): "email": "newuser@example.com", "token": default_token_generator.make_token(newuser), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -220,7 +210,6 @@ class TestRegistration(FixtureAPITestCase): "email": "newuser@example.com", "token": default_token_generator.make_token(newuser), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -243,7 +232,6 @@ class TestRegistration(FixtureAPITestCase): "email": "newuser@example.com", "token": default_token_generator.make_token(newuser), }, - format="json", ) def test_email_verification_no_password(self): @@ -260,7 +248,6 @@ class TestRegistration(FixtureAPITestCase): "email": "newuser@example.com", "token": default_token_generator.make_token(newuser), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) newuser.refresh_from_db() @@ -279,7 +266,6 @@ class TestRegistration(FixtureAPITestCase): "email": "user@user.fr", "token": default_token_generator.make_token(user), }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) # Assert no trial corpus is created @@ -290,7 +276,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.post( reverse("api:verify-email"), data={}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -302,7 +287,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.post( reverse("api:verify-email"), data={"email": self.user.email, "token": "AAAA"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -313,7 +297,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.post( reverse("api:verify-email"), data={"email": "a@bc.de", "token": default_token_generator.make_token(self.user)}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -326,7 +309,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.post( reverse("api:user-new"), data={"display_name": "New user", "email": "newuser@example.com"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertTrue(auth.get_user(self.client).is_authenticated) @@ -343,7 +325,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.post( reverse("api:user-new"), data={"display_name": "New user", "email": "newuser@example.com", "password": "myVerySecretPassword"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertTrue(auth.get_user(self.client).is_authenticated) @@ -366,7 +347,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.post( reverse("api:user-new"), data={"display_name": "New user", "email": "newuser@example.com", "password": pwd}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.json(), {"password": messages}) @@ -379,7 +359,6 @@ class TestRegistration(FixtureAPITestCase): "email": "", "password": "" }, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), { @@ -393,7 +372,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.post( reverse("api:user-new"), data={"email": "newuser@example.com", "password": "myVerySecretPassword"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertListEqual(response.json(), ["Registration has been disabled on this instance."]) @@ -404,7 +382,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.post( reverse("api:user-new"), data={"display_name": "New user", "email": email, "password": "myVerySecretPassword"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"email": ["A user with this email address already exists."]}) @@ -415,7 +392,6 @@ class TestRegistration(FixtureAPITestCase): response = self.client.post( reverse("api:user-new"), data={"display_name": "New user", "email": email, "password": "myVerySecretPassword"}, - format="json", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertDictEqual(response.json(), {"email": ["A user with this email address already exists."]})