def test_cache_manager_configure(): """Test that CacheManager can configure individual caches.""" name = "a" options = {"maxsize": 10, "ttl": 60} cacheman = CacheManager() cacheman.configure(name, **options) assert_cache_options(cacheman[name], options)
def test_cache_manager_configure_class(): """Test that CacheManager can configure caches with a custom cache class.""" cacheman = CacheManager({"a": {"cache_class": MyCache}}) assert isinstance(cacheman["a"], MyCache) cacheman = CacheManager() cacheman.configure("a", cache_class=MyCache) assert isinstance(cacheman["a"], MyCache)
def test_cache_manager_configure(): """Test that CacheManager can configure individual caches.""" name = 'a' options = {'maxsize': 10, 'ttl': 60} cacheman = CacheManager() cacheman.configure(name, **options) assert_cache_options(cacheman[name], options)
def test_cache_manager_configure_class(): """Test that CacheManager can configure caches with a custom cache class. """ cacheman = CacheManager({'a': {'cache_class': MyCache}}) assert isinstance(cacheman['a'], MyCache) cacheman = CacheManager() cacheman.configure('a', cache_class=MyCache) assert isinstance(cacheman['a'], MyCache)
def test_cache_manager_reconfigure(): """Test that CacheManager can reconfigure a previously configured cache.""" name = "a" options = {"maxsize": 10, "ttl": 60} cacheman = CacheManager() cacheman.configure(name, **options) # Store copy of cache to verify identity doesn't change. cache = cacheman[name] new_options = {"maxsize": options["maxsize"] * 2, "ttl": options["ttl"] / 2} cacheman.configure(name, **new_options) assert_cache_options(cacheman[name], new_options) assert cacheman[name] is cache
def test_cache_manager_reconfigure(): """Test that CacheManager can reconfigure a previously configured cache.""" name = 'a' options = {'maxsize': 10, 'ttl': 60} cacheman = CacheManager() cacheman.configure(name, **options) # Store copy of cache to verify identity doesn't change. cache = cacheman[name] new_options = {'maxsize': options['maxsize'] * 2, 'ttl': options['ttl'] / 2} cacheman.configure(name, **new_options) assert_cache_options(cacheman[name], new_options) assert cacheman[name] is cache
def test_cache_manager_default_cache_class(): """Test that CacheManager can use a custom default cache class.""" cacheman = CacheManager(cache_class=MyCache) cacheman.configure("a") assert isinstance(cacheman["a"], MyCache)