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
32848418
Commit
32848418
authored
1 year ago
by
Valentin Rigal
Committed by
Bastien Abadie
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Override IMPORTS_WORKER_VERSION setting on import related tests
parent
6a57bcf1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1980
Override IMPORTS_WORKER_VERSION setting on import related tests
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex/process/tests/test_processes.py
+40
-0
40 additions, 0 deletions
arkindex/process/tests/test_processes.py
with
40 additions
and
0 deletions
arkindex/process/tests/test_processes.py
+
40
−
0
View file @
32848418
...
...
@@ -201,6 +201,7 @@ class TestProcesses(FixtureAPITestCase):
]
})
@override_settings
(
IMPORTS_WORKER_VERSION
=
None
)
def
test_list_with_workflow
(
self
):
"""
Filter processes that have a workflow i.e. that have been started
...
...
@@ -366,6 +367,7 @@ class TestProcesses(FixtureAPITestCase):
self
.
assertEqual
(
len
(
data
[
'
results
'
]),
1
)
self
.
assertEqual
(
data
[
'
results
'
][
0
][
'
id
'
],
str
(
process1
.
id
))
@override_settings
(
IMPORTS_WORKER_VERSION
=
None
)
def
test_list_no_tasks
(
self
):
"""
Ensure the Process reports an Unscheduled state when there are no tasks in its workflow
...
...
@@ -498,6 +500,7 @@ class TestProcesses(FixtureAPITestCase):
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
self
.
assertDictEqual
(
response
.
json
(),
{
'
detail
'
:
'
Authentication credentials were not provided.
'
})
@override_settings
(
IMPORTS_WORKER_VERSION
=
None
)
def
test_details_no_tasks
(
self
):
"""
Ensure the Process reports an Unscheduled state when there are no tasks in its workflow
...
...
@@ -729,6 +732,7 @@ class TestProcesses(FixtureAPITestCase):
self
.
elts_process
.
refresh_from_db
()
self
.
assertEqual
(
self
.
elts_process
.
name
,
'
newName
'
)
@override_settings
(
IMPORTS_WORKER_VERSION
=
None
)
def
test_update_file_import_element
(
self
):
"""
A file import
'
s element can be updated even while it is running
...
...
@@ -1141,6 +1145,7 @@ class TestProcesses(FixtureAPITestCase):
},
format
=
'
json
'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
@override_settings
(
IMPORTS_WORKER_VERSION
=
None
)
def
test_from_files
(
self
):
self
.
client
.
force_login
(
self
.
user
)
response
=
self
.
client
.
post
(
reverse
(
'
api:files-process
'
),
{
...
...
@@ -1156,7 +1161,37 @@ class TestProcesses(FixtureAPITestCase):
self
.
assertEqual
(
process
.
folder_type
.
slug
,
'
volume
'
)
self
.
assertEqual
(
process
.
element_type
.
slug
,
'
page
'
)
self
.
assertIsNone
(
process
.
element
)
recipe
=
yaml
.
safe_load
(
process
.
workflow
.
recipe
)
self
.
assertFalse
(
"
ARKINDEX_WORKER_RUN_ID
"
in
recipe
[
"
env
"
])
def
test_from_files_imports_worker_version
(
self
):
"""
Test files import process with the IMPORTS_WORKER_VERSION setting.
A new worker run will be created specifically for this import.
"""
self
.
client
.
force_login
(
self
.
user
)
self
.
assertEqual
(
self
.
version_with_model
.
worker_runs
.
count
(),
0
)
with
self
.
settings
(
IMPORTS_WORKER_VERSION
=
str
(
self
.
version_with_model
.
id
)):
response
=
self
.
client
.
post
(
reverse
(
'
api:files-process
'
),
{
'
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
()
process
=
Process
.
objects
.
get
(
id
=
data
[
'
id
'
])
self
.
assertEqual
(
process
.
mode
,
ProcessMode
.
Files
)
self
.
assertListEqual
(
list
(
process
.
files
.
all
()),
[
self
.
img_df
])
self
.
assertEqual
(
process
.
folder_type
.
slug
,
'
volume
'
)
self
.
assertEqual
(
process
.
element_type
.
slug
,
'
page
'
)
recipe
=
yaml
.
safe_load
(
process
.
workflow
.
recipe
)
self
.
assertEqual
(
self
.
version_with_model
.
worker_runs
.
count
(),
1
)
self
.
assertEqual
(
recipe
[
"
env
"
][
"
ARKINDEX_WORKER_RUN_ID
"
],
str
(
self
.
version_with_model
.
worker_runs
.
get
().
id
),
)
@override_settings
(
IMPORTS_WORKER_VERSION
=
None
)
def
test_from_files_pdf
(
self
):
self
.
client
.
force_login
(
self
.
user
)
response
=
self
.
client
.
post
(
reverse
(
'
api:files-process
'
),
{
...
...
@@ -1172,6 +1207,7 @@ class TestProcesses(FixtureAPITestCase):
self
.
assertListEqual
(
list
(
process
.
files
.
all
()),
[
self
.
pdf_df
])
self
.
assertIsNone
(
process
.
element
)
@override_settings
(
IMPORTS_WORKER_VERSION
=
None
)
def
test_from_files_image_and_pdf
(
self
):
self
.
client
.
force_login
(
self
.
user
)
response
=
self
.
client
.
post
(
reverse
(
'
api:files-process
'
),
{
...
...
@@ -1244,6 +1280,7 @@ class TestProcesses(FixtureAPITestCase):
},
})
@override_settings
(
IMPORTS_WORKER_VERSION
=
None
)
def
test_from_files_iiif_with_json_charset
(
self
):
self
.
iiif_df
.
content_type
=
'
application/json;charset=utf-8
'
self
.
assertEqual
(
self
.
iiif_df
.
content_type
,
'
application/json;charset=utf-8
'
)
...
...
@@ -1264,6 +1301,7 @@ class TestProcesses(FixtureAPITestCase):
self
.
assertEqual
(
process
.
element_type
.
slug
,
'
page
'
)
self
.
assertIsNone
(
process
.
element
)
@override_settings
(
IMPORTS_WORKER_VERSION
=
None
)
def
test_from_files_iiif_with_json_profile_and_charset
(
self
):
self
.
iiif_df
.
content_type
=
'
application/ld+json;profile=
"
http://iiif.io/api/presentation/2/context.json
"
;charset=utf-8
'
self
.
assertEqual
(
self
.
iiif_df
.
content_type
,
'
application/ld+json;profile=
"
http://iiif.io/api/presentation/2/context.json
"
;charset=utf-8
'
)
...
...
@@ -1328,6 +1366,7 @@ class TestProcesses(FixtureAPITestCase):
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
self
.
assertEqual
(
response
.
json
(),
{
'
non_field_errors
'
:
[
'
File imports can only import images or PDF documents
'
]})
@override_settings
(
IMPORTS_WORKER_VERSION
=
None
)
def
test_from_files_folder_id
(
self
):
self
.
client
.
force_login
(
self
.
user
)
volume
=
self
.
corpus
.
elements
.
get
(
name
=
'
Volume 1
'
)
...
...
@@ -1557,6 +1596,7 @@ class TestProcesses(FixtureAPITestCase):
self
.
assertDictEqual
(
response
.
json
(),
check
)
@override_settings
(
MAX_CHUNKS
=
42
)
@override_settings
(
IMPORTS_WORKER_VERSION
=
None
)
def
test_start_process_serializer_chunks_config
(
self
):
"""
Assert the start process serializer use configuration max chunks
...
...
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