Commit 69643d1f authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

add test for togows utils

parent c9eb07d8
Pipeline #18422 passed with stages
in 2 minutes and 38 seconds
......@@ -28,6 +28,7 @@ jupyter = "*"
factory-boy = "*"
pytest-factoryboy = "*"
pylint = "*"
mock = "*"
[packages]
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)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment