Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
d8ce819b
Commit
d8ce819b
authored
11 months ago
by
Theo Lesage
Committed by
Bastien Abadie
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Fixed broken test from proper already restarted test
parent
c79f8e09
No related branches found
No related tags found
1 merge request
!2304
Link tasks to their restarts
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/ponos/api.py
+1
-3
1 addition, 3 deletions
arkindex/ponos/api.py
arkindex/ponos/tests/test_api.py
+6
-4
6 additions, 4 deletions
arkindex/ponos/tests/test_api.py
with
7 additions
and
7 deletions
arkindex/ponos/api.py
+
1
−
3
View file @
d8ce819b
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
arkindex/ponos/tests/test_api.py
+
6
−
4
View file @
d8ce819b
...
...
@@ -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
(
1
3
):
with
self
.
assertNumQueries
(
1
4
):
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
(
1
3
):
with
self
.
assertNumQueries
(
1
4
):
response
=
self
.
client
.
post
(
reverse
(
"
api:task-restart
"
,
kwargs
=
{
"
pk
"
:
str
(
self
.
task2
.
id
)})
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment