Skip to content

Commit

Permalink
#209: Fix LRU cache test
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Apr 6, 2021
1 parent bdc72fb commit c6e34e8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/icat/test_lru_cache.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest.mock import MagicMock

from cachetools import cached
from icat.client import Client

from datagateway_api.common.config import config
from datagateway_api.common.icat.icat_client_pool import create_client_pool
Expand All @@ -12,15 +13,18 @@ def test_valid_cache_creation(self):
test_cache = ExtendedLRUCache()
assert test_cache.maxsize == config.get_client_cache_size()

def test_valid_popitem(self, icat_client):
def test_valid_popitem(self):
test_cache = ExtendedLRUCache()
test_pool = create_client_pool()
test_client = Client(
config.get_icat_url(), checkCert=config.get_icat_check_cert(),
)

test_cache.popitem = MagicMock(side_effect=test_cache.popitem)

@cached(cache=test_cache)
def get_cached_client(cache_number, client_pool):
return icat_client
return test_client

for cache_number in range(config.get_client_cache_size() + 1):
get_cached_client(cache_number, test_pool)
Expand Down

0 comments on commit c6e34e8

Please sign in to comment.