Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
metagenedb
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Metagenomics
metagenedb
Commits
69643d1f
Commit
69643d1f
authored
5 years ago
by
Kenzo-Hugo Hillion
Browse files
Options
Downloads
Patches
Plain Diff
add test for togows utils
parent
c9eb07d8
No related branches found
No related tags found
2 merge requests
!59
Prod
,
!18
Resolve "Create backend service to perform request to external APIs"
Pipeline
#18422
passed
5 years ago
Stage: build
Stage: test
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
backend/Pipfile
+1
-0
1 addition, 0 deletions
backend/Pipfile
backend/Pipfile.lock
+278
-245
278 additions, 245 deletions
backend/Pipfile.lock
backend/metagenedb/common/utils/external_api/test_togows.py
+29
-0
29 additions, 0 deletions
backend/metagenedb/common/utils/external_api/test_togows.py
with
308 additions
and
245 deletions
backend/Pipfile
+
1
−
0
View file @
69643d1f
...
@@ -28,6 +28,7 @@ jupyter = "*"
...
@@ -28,6 +28,7 @@ jupyter = "*"
factory-boy
=
"*"
factory-boy
=
"*"
pytest-factoryboy
=
"*"
pytest-factoryboy
=
"*"
pylint
=
"*"
pylint
=
"*"
mock
=
"*"
[packages]
[packages]
certifi
=
"*"
certifi
=
"*"
...
...
This diff is collapsed.
Click to expand it.
backend/Pipfile.lock
+
278
−
245
View file @
69643d1f
This diff is collapsed.
Click to expand it.
backend/metagenedb/common/utils/external_api/test_togows.py
+
29
−
0
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
)
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