Commit 27fbcb9a authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion

update last url requested from KEGGAPI and remove togows name

parent 242959c3
Pipeline #35447 passed with stages
in 3 minutes and 42 seconds
......@@ -11,7 +11,7 @@ from metagenedb.api.catalog.qparams_validators.function import (
)
from metagenedb.apps.catalog.models import EggNOG, Function, KeggOrthology
from metagenedb.apps.catalog.serializers import EggNOGSerializer, FunctionSerializer, KeggOrthologySerializer
from metagenedb.common.utils.external_api.togows import GetFunctionExternalInfo
from metagenedb.common.utils.external_api.kegg_api import GetFunctionExternalInfo
from .base import BulkViewSet
......
......@@ -26,7 +26,7 @@ class GetFunctionExternalInfo:
response = kegg_api.get(self.function_id).dict()
response[settings.API_KEY_ADDITIONAL_INFO] = {
'comment': f"Information retrieved from external source: {kegg_api.url}",
'url': f"{kegg_api.url}{self.function_id}"
'url': f"{kegg_api.last_url_requested}"
}
return response
......
......@@ -3,7 +3,7 @@ from unittest import TestCase
import mock
from django.conf import settings
from metagenedb.common.utils.external_api.togows import GetFunctionExternalInfo
from metagenedb.common.utils.external_api.kegg_api import GetFunctionExternalInfo
class TestGetFunctionExternalInfo(TestCase):
......@@ -14,16 +14,18 @@ class TestGetFunctionExternalInfo(TestCase):
external_info_retriever.get_details()
def test_get_details_kegg(self):
with mock.patch('metagenedb.common.utils.external_api.togows.KEGGAPI') as MockKEGGAPI:
test_url = "http://test.com/"
test_id = "id123"
test_last_url = "http://test.com/request_url"
with mock.patch('metagenedb.common.utils.external_api.kegg_api.KEGGAPI') as MockKEGGAPI:
MockKEGGAPI.return_value.get.return_value.dict.return_value = {"info": "some_info"}
test_url = "http://test.com/"
test_id = "test_kegg_id"
MockKEGGAPI.return_value.url = test_url
MockKEGGAPI.return_value.last_url_requested = test_last_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}"
'url': test_last_url
}
}
external_info_retriever = GetFunctionExternalInfo(test_id, "kegg")
......
Markdown is supported
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