def test_dummycache_parsing(self): url = 'dummycache://' url = environ.cache_url_config(url) self.assertEqual(url['BACKEND'], 'django.core.cache.backends.dummy.DummyCache') self.assertEqual(url['LOCATION'], '')
def test_dbcache_parsing(self): url = 'dbcache://my_cache_table' url = environ.cache_url_config(url) self.assertEqual(url['BACKEND'], 'django.core.cache.backends.db.DatabaseCache') self.assertEqual(url['LOCATION'], 'my_cache_table')
def test_locmem_named_parsing(self): url = 'locmemcache://unique-snowflake' url = environ.cache_url_config(url) self.assertEqual(url['BACKEND'], 'django.core.cache.backends.locmem.LocMemCache') self.assertEqual(url['LOCATION'], 'unique-snowflake')
def test_memcache_pylib_parsing(self): url = 'pymemcache://127.0.0.1:11211' url = environ.cache_url_config(url) self.assertEqual(url['BACKEND'], 'django.core.cache.backends.memcached.PyLibMCCache') self.assertEqual(url['LOCATION'], '127.0.0.1:11211')
def test_filecache_windows_parsing(self): url = 'filecache://C:/foo/bar' url = environ.cache_url_config(url) self.assertEqual( url['BACKEND'], 'django.core.cache.backends.filebased.FileBasedCache') self.assertEqual(url['LOCATION'], 'C:/foo/bar')
def test_filecache_parsing(self): url = 'filecache:///var/tmp/django_cache' url = environ.cache_url_config(url) self.assertEqual( url['BACKEND'], 'django.core.cache.backends.filebased.FileBasedCache') self.assertEqual(url['LOCATION'], '/var/tmp/django_cache')
def test_memcache_socket_parsing(self): url = 'memcache:///tmp/memcached.sock' url = environ.cache_url_config(url) self.assertEqual( url['BACKEND'], 'django.core.cache.backends.memcached.MemcachedCache') self.assertEqual(url['LOCATION'], 'unix:/tmp/memcached.sock')
def test_memcache_multiple_parsing(self): url = 'memcache://172.19.26.240:11211,172.19.26.242:11212' url = environ.cache_url_config(url) self.assertEqual( url['BACKEND'], 'django.core.cache.backends.memcached.MemcachedCache') self.assertEqual(url['LOCATION'], ['172.19.26.240:11211', '172.19.26.242:11212'])
def test_redis_parsing(self): url = 'rediscache://127.0.0.1:6379:1?client_class=redis_cache.client.DefaultClient&password=secret' url = environ.cache_url_config(url) self.assertEqual(url['BACKEND'], 'redis_cache.cache.RedisCache') self.assertEqual(url['LOCATION'], '127.0.0.1:6379:1') self.assertEqual(url['OPTIONS'], { 'CLIENT_CLASS': 'redis_cache.client.DefaultClient', 'PASSWORD': '******', })
def test_redis_parsing(self): url = 'rediscache://127.0.0.1:6379:1?client_class=redis_cache.client.DefaultClient&password=secret' url = environ.cache_url_config(url) self.assertEqual(url['BACKEND'], 'redis_cache.cache.RedisCache') self.assertEqual(url['LOCATION'], '127.0.0.1:6379:1') self.assertEqual( url['OPTIONS'], { 'CLIENT_CLASS': 'redis_cache.client.DefaultClient', 'PASSWORD': '******', })
def test_custom_backend(self): url = 'memcache://127.0.0.1:5400?foo=option&bars=9001' backend = 'redis_cache.cache.RedisCache' url = environ.cache_url_config(url, backend) self.assertEqual(url['BACKEND'], backend) self.assertEqual(url['LOCATION'], '127.0.0.1:5400') self.assertEqual(url['OPTIONS'], { 'FOO': 'option', 'BARS': 9001, })
def test_options_parsing(self): url = 'filecache:///var/tmp/django_cache?timeout=60&max_entries=1000&cull_frequency=0' url = environ.cache_url_config(url) self.assertEqual(url['BACKEND'], 'django.core.cache.backends.filebased.FileBasedCache') self.assertEqual(url['LOCATION'], '/var/tmp/django_cache') self.assertEqual(url['TIMEOUT'], 60) self.assertEqual(url['OPTIONS'], { 'MAX_ENTRIES': 1000, 'CULL_FREQUENCY': 0, })
def test_options_parsing(self): url = 'filecache:///var/tmp/django_cache?timeout=60&max_entries=1000&cull_frequency=0' url = environ.cache_url_config(url) self.assertEqual( url['BACKEND'], 'django.core.cache.backends.filebased.FileBasedCache') self.assertEqual(url['LOCATION'], '/var/tmp/django_cache') self.assertEqual(url['TIMEOUT'], 60) self.assertEqual(url['OPTIONS'], { 'MAX_ENTRIES': 1000, 'CULL_FREQUENCY': 0, })
def test_redis_socket_parsing(self): url = 'rediscache:///path/to/socket:1' url = environ.cache_url_config(url) self.assertEqual(url['BACKEND'], 'redis_cache.cache.RedisCache') self.assertEqual(url['LOCATION'], 'unix:/path/to/socket:1')
def test_filecache_windows_parsing(self): url = 'filecache://C:/foo/bar' url = environ.cache_url_config(url) self.assertEqual(url['BACKEND'], 'django.core.cache.backends.filebased.FileBasedCache') self.assertEqual(url['LOCATION'], 'C:/foo/bar')
def test_filecache_parsing(self): url = 'filecache:///var/tmp/django_cache' url = environ.cache_url_config(url) self.assertEqual(url['BACKEND'], 'django.core.cache.backends.filebased.FileBasedCache') self.assertEqual(url['LOCATION'], '/var/tmp/django_cache')
def test_memcache_socket_parsing(self): url = 'memcache:///tmp/memcached.sock' url = environ.cache_url_config(url) self.assertEqual(url['BACKEND'], 'django.core.cache.backends.memcached.MemcachedCache') self.assertEqual(url['LOCATION'], 'unix:/tmp/memcached.sock')
def test_memcache_multiple_parsing(self): url = 'memcache://172.19.26.240:11211,172.19.26.242:11212' url = environ.cache_url_config(url) self.assertEqual(url['BACKEND'], 'django.core.cache.backends.memcached.MemcachedCache') self.assertEqual(url['LOCATION'], ['172.19.26.240:11211', '172.19.26.242:11212'])