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
0d602442
Commit
0d602442
authored
5 years ago
by
Erwan Rouchet
Committed by
Bastien Abadie
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix TypeError when a DataImport has an empty workflow
parent
010de0eb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!582
Fix TypeError when a DataImport has an empty workflow
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/dataimport/models.py
+3
-0
3 additions, 0 deletions
arkindex/dataimport/models.py
arkindex/dataimport/tests/test_imports.py
+13
-0
13 additions, 0 deletions
arkindex/dataimport/tests/test_imports.py
with
16 additions
and
0 deletions
arkindex/dataimport/models.py
+
3
−
0
View file @
0d602442
...
...
@@ -39,6 +39,9 @@ class DataImport(IndexableModel):
return
State
.
Unscheduled
# This allows annotating a DataImport queryset with "last_run" and preventing duplicate SQL queries
if
hasattr
(
self
,
'
last_run
'
):
# last_run may be None when there is a workflow without any tasks
if
self
.
last_run
is
None
:
return
State
.
Unscheduled
return
self
.
workflow
.
get_state
(
self
.
last_run
)
else
:
return
self
.
workflow
.
state
...
...
This diff is collapsed.
Click to expand it.
arkindex/dataimport/tests/test_imports.py
+
13
−
0
View file @
0d602442
...
...
@@ -133,6 +133,19 @@ class TestImports(FixtureAPITestCase):
data
=
response
.
json
()
self
.
assertEqual
(
data
[
'
id
'
],
str
(
self
.
dataimport
.
id
))
def
test_details_no_tasks
(
self
):
"""
Ensure the DataImport reports an Unscheduled state when there are no tasks in its workflow
"""
self
.
assertIsNone
(
self
.
dataimport
.
workflow
)
self
.
dataimport
.
start
()
self
.
dataimport
.
workflow
.
tasks
.
all
().
delete
()
self
.
client
.
force_login
(
self
.
user
)
response
=
self
.
client
.
get
(
reverse
(
'
api:import-details
'
,
kwargs
=
{
'
pk
'
:
self
.
dataimport
.
id
}))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
data
=
response
.
json
()
self
.
assertEqual
(
data
[
'
state
'
],
'
unscheduled
'
)
def
test_retry_requires_login
(
self
):
response
=
self
.
client
.
post
(
reverse
(
'
api:import-retry
'
,
kwargs
=
{
'
pk
'
:
self
.
dataimport
.
id
}))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
...
...
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