Skip to content
Snippets Groups Projects
Commit bd7b288c authored by Theo Lesage's avatar Theo Lesage
Browse files

Fixed broken test from proper already restarted test

parent c7635321
No related merge requests found
This commit is part of merge request !2304. Comments created here will be created in the context of that merge request.
......@@ -223,11 +223,9 @@ class TaskRestart(ProcessACLMixin, CreateAPIView):
raise ValidationError(
detail="Task's state must be in a final state to be restarted."
)
# TODO Check the original_task_id field directly once it is implemented
# https://gitlab.teklia.com/arkindex/frontend/-/issues/1383
if len(Task.objects.filter(original_task=task)) > 0:
raise ValidationError(
detail="This task has already been restarted"
detail="This task has already been restarted."
)
return task
......
......@@ -589,14 +589,16 @@ class TestAPI(FixtureAPITestCase):
self.task1.slug = self.task1.slug + "_old1"
self.task1.state = State.Completed.value
self.task1.save()
with self.assertNumQueries(7):
self.task2.original_task_id = self.task1.id
self.task2.save()
with self.assertNumQueries(8):
response = self.client.post(
reverse("api:task-restart", kwargs={"pk": str(self.task1.id)})
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertListEqual(
response.json(),
["This task has already been restarted"],
["This task has already been restarted."],
)
@patch("arkindex.project.aws.s3")
......@@ -641,7 +643,7 @@ class TestAPI(FixtureAPITestCase):
self.task2.save()
self.client.force_login(self.user)
with self.assertNumQueries(13):
with self.assertNumQueries(14):
with patch("django.utils.timezone.now") as mock_now:
mock_now.return_value = datetime.now(timezone.utc) + timedelta(minutes=2)
response = self.client.post(
......@@ -708,7 +710,7 @@ class TestAPI(FixtureAPITestCase):
self.task2.save()
self.client.force_login(self.user)
with self.assertNumQueries(13):
with self.assertNumQueries(14):
response = self.client.post(
reverse("api:task-restart", kwargs={"pk": str(self.task2.id)})
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment