Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
PEDASI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Research Software Group
PEDASI
Commits
b597c2fa
Commit
b597c2fa
authored
Aug 30, 2018
by
James Graham
Browse files
Options
Downloads
Patches
Plain Diff
Remove duplicated code from HyperCat connector get_metadata
parent
d04e08e2
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
datasources/connectors/hypercat.py
+11
-11
11 additions, 11 deletions
datasources/connectors/hypercat.py
datasources/tests/test_connectors.py
+2
-7
2 additions, 7 deletions
datasources/tests/test_connectors.py
with
13 additions
and
18 deletions
datasources/connectors/hypercat.py
+
11
−
11
View file @
b597c2fa
import
copy
import
typing
import
requests
...
...
@@ -31,22 +30,23 @@ class HyperCat(DataConnectorContainsDatasets, DataConnectorHasMetadata, BaseData
def
get_metadata
(
self
,
dataset
:
typing
.
Optional
[
str
]
=
None
,
query_params
:
typing
.
Optional
[
typing
.
Mapping
[
str
,
str
]]
=
None
):
response
=
self
.
_response
if
query_params
is
None
:
query_params
=
{}
if
dataset
is
None
:
if
dataset
is
not
None
:
# Copy so we can update without side effect
query_params
=
dict
(
query_params
)
query_params
[
'
href
'
]
=
dataset
# Use cached response if we have one
response
=
self
.
_response
if
response
is
None
:
response
=
self
.
_get_response
(
query_params
)
if
dataset
is
None
:
metadata
=
response
[
'
catalogue-metadata
'
]
else
:
query_params
=
copy
.
copy
(
query_params
).
update
({
'
href
'
:
dataset
})
if
response
is
None
:
response
=
self
.
_get_response
(
query_params
)
dataset_item
=
self
.
_get_item_by_key_value
(
response
[
'
items
'
],
'
href
'
,
...
...
This diff is collapsed.
Click to expand it.
datasources/tests/test_connectors.py
+
2
−
7
View file @
b597c2fa
...
...
@@ -93,14 +93,9 @@ class ConnectorHyperCatTest(TestCase):
connection
=
self
.
plugin
(
self
.
url
)
self
.
assertEqual
(
connection
.
location
,
self
.
url
)
def
test_plugin_get_metadata
_query
(
self
):
def
test_plugin_get_
dataset_
metadata
(
self
):
connection
=
self
.
plugin
(
self
.
url
)
result
=
connection
.
get_metadata
(
dataset
=
self
.
dataset
,
query_params
=
{
'
href
'
:
self
.
dataset
}
)
result
=
connection
.
get_metadata
(
dataset
=
self
.
dataset
)
for
property
in
[
'
urn:X-bt:rels:feedTitle
'
,
...
...
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