Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Metagenomics
metagenedb
Commits
69643d1f
Commit
69643d1f
authored
Nov 18, 2019
by
Kenzo-Hugo Hillion
♻
Browse files
add test for togows utils
parent
c9eb07d8
Pipeline
#18422
passed with stages
in 2 minutes and 38 seconds
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
backend/Pipfile
View file @
69643d1f
...
...
@@ -28,6 +28,7 @@ jupyter = "*"
factory-boy
=
"*"
pytest-factoryboy
=
"*"
pylint
=
"*"
mock
=
"*"
[packages]
certifi
=
"*"
...
...
backend/Pipfile.lock
View file @
69643d1f
This diff is collapsed.
Click to expand it.
backend/metagenedb/common/utils/external_api/test_togows.py
View file @
69643d1f
from
unittest
import
TestCase
import
mock
from
django.conf
import
settings
from
metagenedb.common.utils.external_api.togows
import
GetFunctionExternalInfo
class
TestGetFunctionExternalInfo
(
TestCase
):
def
test_get_details_unknown_source
(
self
):
external_info_retriever
=
GetFunctionExternalInfo
(
"test_id"
,
"unknown"
)
self
.
assertDictEqual
(
external_info_retriever
.
get_details
(),
{})
def
test_get_details_kegg
(
self
):
with
mock
.
patch
(
'metagenedb.common.utils.external_api.togows.TogoWSEntryAPI'
)
as
MockTogoWSEntryAPI
:
MockTogoWSEntryAPI
.
return_value
.
get
.
return_value
=
[{
"info"
:
"some_info"
}]
test_url
=
"http://test.com/"
test_id
=
"test_kegg_id"
MockTogoWSEntryAPI
.
return_value
.
url
=
test_url
expected_dict
=
{
'info'
:
'some_info'
,
settings
.
API_KEY_ADDITIONAL_INFO
:
{
'comment'
:
f
"Information retrieved from external source:
{
test_url
}
"
,
'url'
:
f
"
{
test_url
}{
test_id
}
"
}
}
external_info_retriever
=
GetFunctionExternalInfo
(
test_id
,
"kegg"
)
self
.
assertDictEqual
(
external_info_retriever
.
get_details
(),
expected_dict
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment