Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
File
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Workers
Import
File
Commits
5b8d139f
Verified
Commit
5b8d139f
authored
3 months ago
by
Erwan Rouchet
Browse files
Options
Downloads
Patches
Plain Diff
Handle query parameters when retrieving IIIF image information
parent
3f52cbe6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!11
Handle query parameters when retrieving IIIF image information
Pipeline
#202780
passed
3 months ago
Stage: test
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_iiif_manifest_parser.py
+17
-8
17 additions, 8 deletions
tests/test_iiif_manifest_parser.py
worker_file_import/iiif.py
+6
-1
6 additions, 1 deletion
worker_file_import/iiif.py
with
23 additions
and
9 deletions
tests/test_iiif_manifest_parser.py
+
17
−
8
View file @
5b8d139f
...
...
@@ -106,23 +106,32 @@ def test_create_metadata_url(mock_worker):
)
def
test_get_image
(
mock_worker
,
responses
):
responses
.
add
(
responses
.
GET
,
"
http://imageurl/info.json
"
,
json
=
{
"
@id
"
:
"
http://imageurl/
"
}
)
@pytest.mark.parametrize
(
(
"
image_id
"
,
"
expected_url
"
),
[
(
"
http://imageurl/
"
,
"
http://imageurl/info.json
"
),
(
"
http://imageurl/a/b/c
"
,
"
http://imageurl/a/b/c/info.json
"
),
# Path parameters should be left as they are
(
"
http://imageurl/a/b;k=v/c
"
,
"
http://imageurl/a/b;k=v/c/info.json
"
),
# Query parameters are treated as part of the path to handle non-standard servers
(
"
http://imageurl/a/b/c?k=v
"
,
"
http://imageurl/a/b/c?k=v/info.json
"
),
],
)
def
test_get_image
(
mock_worker
,
responses
,
image_id
,
expected_url
):
responses
.
add
(
responses
.
GET
,
expected_url
,
json
=
{
"
@id
"
:
"
http://imageurl/
"
})
mock_worker
.
api_client
.
add_response
(
"
CreateIIIFInformation
"
,
body
=
{
"
@id
"
:
"
http://imageurl/
"
},
response
=
{
"
id
"
:
"
imageid
"
,
"
url
"
:
"
http://
image
url
"
,
"
status
"
:
"
checked
"
},
response
=
{
"
id
"
:
"
imageid
"
,
"
url
"
:
image
_id
,
"
status
"
:
"
checked
"
},
)
parser
=
ManifestParser
(
mock_worker
,
BytesIO
())
assert
parser
.
get_image
(
"
http://
image
url
"
)
==
{
assert
parser
.
get_image
(
image
_id
)
==
{
"
id
"
:
"
imageid
"
,
"
url
"
:
"
http://
image
url
"
,
"
url
"
:
image
_id
,
"
status
"
:
"
checked
"
,
}
responses
.
assert_call_count
(
"
http://imageurl/info.json
"
,
1
)
responses
.
assert_call_count
(
expected_url
,
1
)
def
test_get_image_check_error
(
mock_worker
,
responses
):
...
...
This diff is collapsed.
Click to expand it.
worker_file_import/iiif.py
+
6
−
1
View file @
5b8d139f
...
...
@@ -255,10 +255,15 @@ class ManifestParser(IIIFParser):
Get or create an Arkindex image from an IIIF image URL.
Returns None if the image could not be created.
"""
parsed_url
=
urlparse
(
url
)
if
not
url
.
endswith
(
"
/
"
):
url
+=
"
/
"
info_url
=
urljoin
(
url
,
"
info.json
"
)
# When the image URL has a query parameter, concatenate strings instead of using `urljoin`
# because some servers do not do any URL rewriting and put the image identifier in a query parameter
info_url
=
url
+
"
info.json
"
if
parsed_url
.
query
else
urljoin
(
url
,
"
info.json
"
)
try
:
payload
=
self
.
fetch_image_information
(
info_url
)
except
Exception
as
e
:
...
...
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