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
a406bd40
Commit
a406bd40
authored
6 years ago
by
James Graham
Browse files
Options
Downloads
Patches
Plain Diff
Add determine_auth tests for base connector and hypercat
parent
dac77740
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
datasources/connectors/base.py
+1
-0
1 addition, 0 deletions
datasources/connectors/base.py
datasources/tests/test_connectors.py
+8
-1
8 additions, 1 deletion
datasources/tests/test_connectors.py
datasources/tests/test_connectors_hypercat.py
+9
-1
9 additions, 1 deletion
datasources/tests/test_connectors_hypercat.py
with
18 additions
and
2 deletions
datasources/connectors/base.py
+
1
−
0
View file @
a406bd40
...
@@ -100,6 +100,7 @@ class BaseDataConnector(metaclass=plugin.Plugin):
...
@@ -100,6 +100,7 @@ class BaseDataConnector(metaclass=plugin.Plugin):
def
request_count
(
self
):
def
request_count
(
self
):
return
self
.
_request_counter
.
count
()
return
self
.
_request_counter
.
count
()
# TODO make normal method
@staticmethod
@staticmethod
def
determine_auth_method
(
url
:
str
,
api_key
:
str
)
->
AuthMethod
:
def
determine_auth_method
(
url
:
str
,
api_key
:
str
)
->
AuthMethod
:
"""
"""
...
...
This diff is collapsed.
Click to expand it.
datasources/tests/test_connectors.py
+
8
−
1
View file @
a406bd40
from
django.test
import
TestCase
from
django.test
import
TestCase
from
datasources.connectors.base
import
BaseDataConnector
from
datasources.connectors.base
import
AuthMethod
,
BaseDataConnector
class
ConnectorPluginTest
(
TestCase
):
class
ConnectorPluginTest
(
TestCase
):
...
@@ -86,6 +86,13 @@ class ConnectorIoTUKTest(TestCase):
...
@@ -86,6 +86,13 @@ class ConnectorIoTUKTest(TestCase):
self
.
assertIn
(
'
data
'
,
result
)
self
.
assertIn
(
'
data
'
,
result
)
self
.
assertGreater
(
len
(
result
[
'
data
'
]),
0
)
self
.
assertGreater
(
len
(
result
[
'
data
'
]),
0
)
def
test_determine_auth
(
self
):
connection
=
self
.
_get_connection
()
auth_method
=
connection
.
determine_auth_method
(
connection
.
location
,
connection
.
api_key
)
self
.
assertEqual
(
AuthMethod
.
NONE
,
auth_method
)
class
ConnectorRestApiTest
(
TestCase
):
class
ConnectorRestApiTest
(
TestCase
):
url
=
'
https://api.iotuk.org.uk/
'
url
=
'
https://api.iotuk.org.uk/
'
...
...
This diff is collapsed.
Click to expand it.
datasources/tests/test_connectors_hypercat.py
+
9
−
1
View file @
a406bd40
...
@@ -4,7 +4,7 @@ import typing
...
@@ -4,7 +4,7 @@ import typing
from
django.test
import
TestCase
from
django.test
import
TestCase
from
requests.auth
import
HTTPBasicAuth
from
requests.auth
import
HTTPBasicAuth
from
datasources.connectors.base
import
BaseDataConnector
,
HttpHeaderAuth
from
datasources.connectors.base
import
AuthMethod
,
BaseDataConnector
,
HttpHeaderAuth
def
_get_item_by_key_value
(
collection
:
typing
.
Iterable
[
typing
.
Mapping
],
def
_get_item_by_key_value
(
collection
:
typing
.
Iterable
[
typing
.
Mapping
],
...
@@ -181,6 +181,7 @@ class ConnectorHyperCatTest(TestCase):
...
@@ -181,6 +181,7 @@ class ConnectorHyperCatTest(TestCase):
class
ConnectorHyperCatCiscoTest
(
TestCase
):
class
ConnectorHyperCatCiscoTest
(
TestCase
):
# TODO find working dataset
url
=
'
https://api.cityverve.org.uk/v1/cat
'
url
=
'
https://api.cityverve.org.uk/v1/cat
'
subcatalogue
=
'
https://api.cityverve.org.uk/v1/cat/polling-station
'
subcatalogue
=
'
https://api.cityverve.org.uk/v1/cat/polling-station
'
dataset
=
'
https://api.cityverve.org.uk/v1/entity/polling-station/5
'
dataset
=
'
https://api.cityverve.org.uk/v1/entity/polling-station/5
'
...
@@ -212,6 +213,13 @@ class ConnectorHyperCatCiscoTest(TestCase):
...
@@ -212,6 +213,13 @@ class ConnectorHyperCatCiscoTest(TestCase):
self
.
assertTrue
(
connection
.
is_catalogue
)
self
.
assertTrue
(
connection
.
is_catalogue
)
def
test_determine_auth
(
self
):
connection
=
self
.
_get_connection
()
auth_method
=
connection
.
determine_auth_method
(
connection
.
location
,
connection
.
api_key
)
self
.
assertEqual
(
AuthMethod
.
HEADER
,
auth_method
)
def
test_plugin_get_catalogue_metadata
(
self
):
def
test_plugin_get_catalogue_metadata
(
self
):
connection
=
self
.
_get_connection
()
connection
=
self
.
_get_connection
()
...
...
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