Esempio n. 1
0
    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'], '')
Esempio n. 2
0
    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')
Esempio n. 3
0
    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')
Esempio n. 4
0
    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')
Esempio n. 5
0
    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')
Esempio n. 6
0
    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')
Esempio n. 7
0
    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')
Esempio n. 8
0
    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'])
Esempio n. 9
0
    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': '******',
        })
Esempio n. 10
0
    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': '******',
            })
Esempio n. 11
0
    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,
        })
Esempio n. 12
0
    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,
        })
Esempio n. 13
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,
        })
Esempio n. 14
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,
        })
Esempio n. 15
0
    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')
Esempio n. 16
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')
Esempio n. 17
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')
Esempio n. 18
0
    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'], '')
Esempio n. 19
0
    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')
Esempio n. 20
0
    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')
Esempio n. 21
0
    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')
Esempio n. 22
0
    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')
Esempio n. 23
0
    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')
Esempio n. 24
0
    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'])