From ebe9c167ed0cd4a7c8eb7f2068318565d8d274d0 Mon Sep 17 00:00:00 2001 From: "patrick.qian" Date: Wed, 22 Feb 2023 09:38:33 +0100 Subject: [PATCH] fix failure of caching instances list --- source/jormungandr/jormungandr/instance_manager.py | 4 ++-- .../jormungandr/tests/instance_manager_tests.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/jormungandr/jormungandr/instance_manager.py b/source/jormungandr/jormungandr/instance_manager.py index 56a47d95a1..cb57e50e74 100644 --- a/source/jormungandr/jormungandr/instance_manager.py +++ b/source/jormungandr/jormungandr/instance_manager.py @@ -298,7 +298,7 @@ def get_instances(self, name=None, lon=None, lat=None, object_id=None, api='ALL' else: # Requests without any coverage # fetch all the authorized instances (free + private) using cached function has_access() - authorized_instances_name = self.get_all_available_instances(user) + authorized_instances_name = self.get_all_available_instances_names(user) authorized_instances = [self.instances[i_name] for i_name in authorized_instances_name] if not authorized_instances: # user doesn't have access to any of the instances @@ -346,7 +346,7 @@ def regions(self, region=None, lon=None, lat=None, request_id=None): @memory_cache.memoize(app.config[str('MEMORY_CACHE_CONFIGURATION')].get(str('TIMEOUT_AUTHENTICATION'), 30)) @cache.memoize(app.config[str('CACHE_CONFIGURATION')].get(str('TIMEOUT_AUTHENTICATION'), 300)) - def get_all_available_instances(self, user): + def get_all_available_instances_names(self, user): result = [] if app.config.get('PUBLIC', False) or app.config.get('DISABLE_DATABASE', False): return [key for key in self.instances] diff --git a/source/jormungandr/jormungandr/tests/instance_manager_tests.py b/source/jormungandr/jormungandr/tests/instance_manager_tests.py index 1897486dbe..d7fb9f2efa 100644 --- a/source/jormungandr/jormungandr/tests/instance_manager_tests.py +++ b/source/jormungandr/jormungandr/tests/instance_manager_tests.py @@ -55,8 +55,8 @@ def manager(): def get_instances_test(manager, mocker): mock = mocker.patch.object( manager, - 'get_all_available_instances', - return_value=[manager.instances['paris'], manager.instances['pdl']], + 'get_all_available_instances_names', + return_value=['paris', 'pdl'], ) with app.test_request_context('/'): instances = manager.get_instances() @@ -74,8 +74,8 @@ def get_instances_by_coord_test(manager, mocker): ) mock = mocker.patch.object( manager, - 'get_all_available_instances', - return_value=[manager.instances['paris'], manager.instances['pdl']], + 'get_all_available_instances_names', + return_value=['paris', 'pdl'], ) with app.test_request_context('/'): instances = manager.get_instances(lon=4, lat=3) @@ -88,8 +88,8 @@ def get_instances_by_object_id_test(manager, mocker): mock = mocker.patch.object(manager, '_all_keys_of_id_in_instances', return_value=[manager.instances['pdl']]) mock = mocker.patch.object( manager, - 'get_all_available_instances', - return_value=[manager.instances['paris'], manager.instances['pdl']], + 'get_all_available_instances_names', + return_value=['paris', 'pdl'], ) with app.test_request_context('/'): instances = manager.get_instances(object_id='sa:pdl')