Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Tasks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Arkindex
Tasks
Commits
5588ceb5
Commit
5588ceb5
authored
1 year ago
by
ml bonhomme
Committed by
Erwan Rouchet
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Do not publish downloaded files as artifacts
parent
0c6c91bd
No related branches found
No related tags found
1 merge request
!362
Do not publish downloaded files as artifacts
Pipeline
#137552
passed
1 year ago
Stage: release
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
arkindex_tasks/base.py
+2
-1
2 additions, 1 deletion
arkindex_tasks/base.py
tests/import_iiif/test_process.py
+13
-3
13 additions, 3 deletions
tests/import_iiif/test_process.py
tests/test_base.py
+14
-3
14 additions, 3 deletions
tests/test_base.py
with
29 additions
and
7 deletions
arkindex_tasks/base.py
+
2
−
1
View file @
5588ceb5
...
...
@@ -79,10 +79,11 @@ class ProcessTask(object):
return
ProcessMode
(
self
.
process
[
"
mode
"
])
def
download_files
(
self
):
temp_path
=
tempfile
.
mkdtemp
()
files
=
[]
for
datafile_id
in
self
.
process
[
"
files
"
]:
df
=
default_client
.
request
(
"
RetrieveDataFile
"
,
id
=
datafile_id
)
path
=
get_working_dir
(
)
/
datafile_id
path
=
Path
(
temp_path
)
/
datafile_id
logger
.
info
(
"
Downloading file {} ({})
"
.
format
(
df
[
"
name
"
],
df
[
"
id
"
]))
try
:
...
...
This diff is collapsed.
Click to expand it.
tests/import_iiif/test_process.py
+
13
−
3
View file @
5588ceb5
# -*- coding: utf-8 -*-
import
json
import
shutil
import
tempfile
from
argparse
import
Namespace
from
io
import
BufferedReader
from
pathlib
import
Path
...
...
@@ -24,6 +26,12 @@ SAMPLES = Path(__file__).absolute().parent / "samples"
)
@requests_mock.Mocker
()
class
TestProcess
(
TestCase
):
def
setUp
(
self
):
self
.
tmp_dir
=
tempfile
.
mkdtemp
()
def
tearDown
(
self
):
shutil
.
rmtree
(
Path
(
self
.
tmp_dir
))
def
test_not_found
(
self
,
args_mock
,
parser_mock
,
req_mock
):
process_id
=
uuid4
()
req_mock
.
get
(
...
...
@@ -125,7 +133,8 @@ class TestProcess(TestCase):
main
()
self
.
assertEqual
(
default_client
.
sleep_duration
,
0.01
)
def
test_run
(
self
,
args_mock
,
parser_mock
,
req_mock
):
@patch
(
"
arkindex_tasks.base.tempfile
"
)
def
test_run
(
self
,
req_mock
,
temp_mock
,
args_mock
,
parser_mock
):
process_id
=
uuid4
()
req_mock
.
get
(
"
/api/v1/process/{}/
"
.
format
(
process_id
),
...
...
@@ -165,6 +174,7 @@ class TestProcess(TestCase):
req_mock
.
delete
(
"
/api/v1/process/file/file1/
"
,
status_code
=
204
)
req_mock
.
delete
(
"
/api/v1/process/file/file2/
"
,
status_code
=
204
)
temp_mock
.
mkdtemp
.
return_value
=
self
.
tmp_dir
args_mock
().
parse_args
.
return_value
=
Namespace
(
process_id
=
process_id
,
sleep
=
0
,
...
...
@@ -183,7 +193,7 @@ class TestProcess(TestCase):
args
,
kwargs
=
call1
self
.
assertEqual
(
len
(
args
),
1
)
self
.
assertIsInstance
(
args
[
0
],
BufferedReader
)
self
.
assertEqual
(
args
[
0
].
name
,
str
(
get_working
_dir
(
)
/
"
file1
"
))
self
.
assertEqual
(
args
[
0
].
name
,
str
(
Path
(
self
.
tmp
_dir
)
/
"
file1
"
))
self
.
assertDictEqual
(
kwargs
,
{
...
...
@@ -195,7 +205,7 @@ class TestProcess(TestCase):
args
,
kwargs
=
call2
self
.
assertEqual
(
len
(
args
),
1
)
self
.
assertIsInstance
(
args
[
0
],
BufferedReader
)
self
.
assertEqual
(
args
[
0
].
name
,
str
(
get_working
_dir
(
)
/
"
file2
"
))
self
.
assertEqual
(
args
[
0
].
name
,
str
(
Path
(
self
.
tmp
_dir
)
/
"
file2
"
))
self
.
assertDictEqual
(
kwargs
,
{
...
...
This diff is collapsed.
Click to expand it.
tests/test_base.py
+
14
−
3
View file @
5588ceb5
# -*- coding: utf-8 -*-
import
shutil
import
tempfile
from
pathlib
import
Path
from
unittest
import
TestCase
from
unittest.mock
import
patch
...
...
@@ -12,6 +14,12 @@ SAMPLES = Path(__file__).absolute().parent / "samples"
@patch
(
"
arkindex_tasks.utils.download_file.retry.wait.wait_fixed
"
,
new
=
0
)
class
TestBase
(
TestCase
):
def
setUp
(
self
):
self
.
tmp_dir
=
tempfile
.
mkdtemp
()
def
tearDown
(
self
):
shutil
.
rmtree
(
Path
(
self
.
tmp_dir
))
def
test_default_working_dir
(
self
):
arkindex_tasks
.
base
.
_working_dir
=
None
try
:
...
...
@@ -44,13 +52,16 @@ class TestBase(TestCase):
self
.
assertDictEqual
(
task
.
process
,
{
"
id
"
:
"
processid
"
})
@requests_mock.Mocker
()
def
test_download_files
(
self
,
mock
):
@patch
(
"
arkindex_tasks.base.tempfile
"
)
def
test_download_files
(
self
,
mock
,
temp_mock
):
mock
.
get
(
"
/api/v1/process/file/file1/
"
,
json
=
{
"
id
"
:
"
file1
"
,
"
name
"
:
"
img1.jpg
"
,
"
s3_url
"
:
"
http://s3/img1.jpg
"
},
)
mock
.
get
(
"
http://s3/img1.jpg
"
,
body
=
open
(
SAMPLES
/
"
img1.jpg
"
,
"
rb
"
))
temp_mock
.
mkdtemp
.
return_value
=
self
.
tmp_dir
task
=
arkindex_tasks
.
base
.
ProcessTask
(
"
processid
"
)
task
.
process
=
{
"
id
"
:
"
processid
"
,
"
files
"
:
[
"
file1
"
]}
...
...
@@ -62,12 +73,12 @@ class TestBase(TestCase):
"
id
"
:
"
file1
"
,
"
name
"
:
"
img1.jpg
"
,
"
s3_url
"
:
"
http://s3/img1.jpg
"
,
"
local_path
"
:
arkindex_tasks
.
base
.
get_working
_dir
(
)
/
"
file1
"
,
"
local_path
"
:
Path
(
self
.
tmp
_dir
)
/
"
file1
"
,
}
],
)
self
.
assertTrue
((
arkindex_tasks
.
base
.
get_working
_dir
(
)
/
"
file1
"
).
is_file
())
self
.
assertTrue
((
Path
(
self
.
tmp
_dir
)
/
"
file1
"
).
is_file
())
self
.
assertEqual
(
mock
.
call_count
,
2
)
@requests_mock.Mocker
()
...
...
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