Skip to content
Snippets Groups Projects
Commit 69643d1f authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion :recycle:
Browse files

add test for togows utils

parent c9eb07d8
No related branches found
No related tags found
2 merge requests!59Prod,!18Resolve "Create backend service to perform request to external APIs"
Pipeline #18422 passed
...@@ -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.
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment