Skip to content

Commit

Permalink
fix failure of caching instances list
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick.qian committed Feb 22, 2023
1 parent 83ad057 commit ebe9c16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions source/jormungandr/jormungandr/instance_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
12 changes: 6 additions & 6 deletions source/jormungandr/jormungandr/tests/instance_manager_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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')
Expand Down

0 comments on commit ebe9c16

Please sign in to comment.