Ejemplo n.º 1
0
    def test_dummy_parsing(self):
        url = 'dummy://foo'
        url = dj_cache_url.parse(url)

        self.assertEqual(url['BACKEND'],
                         'django.core.cache.backends.dummy.DummyCache')
        self.assertNotIn('LOCATION', url)
Ejemplo n.º 2
0
    def test_db_parsing(self):
        url = 'db://foo'
        url = dj_cache_url.parse(url)

        self.assertEqual(url['BACKEND'],
                         'django.core.cache.backends.db.DatabaseCache')
        self.assertEqual(url['LOCATION'], 'foo')
Ejemplo n.º 3
0
    def test_locmem_parsing(self):
        url = 'locmem://foo'
        url = dj_cache_url.parse(url)

        self.assertEqual(url['BACKEND'],
                         'django.core.cache.backends.locmem.LocMemCache')
        self.assertEqual(url['LOCATION'], 'foo')
Ejemplo n.º 4
0
    def test_options(self):
        url = 'memcached://127.0.0.1:11211?MAX_ENTRIES=1'
        url = dj_cache_url.parse(url)

        self.assertIn('OPTIONS', url)
        self.assertIn('MAX_ENTRIES', url['OPTIONS'])
        self.assertEqual(url['OPTIONS']['MAX_ENTRIES'], '1')
Ejemplo n.º 5
0
    def test_file_parsing(self):
        url = 'file:///tmp/foo'
        url = dj_cache_url.parse(url)

        self.assertEqual(
            url['BACKEND'],
            'django.core.cache.backends.filebased.FileBasedCache')
        self.assertEqual(url['LOCATION'], '/tmp/foo')
Ejemplo n.º 6
0
    def test_memcached_parsing(self):
        url = 'memcached://127.0.0.1:11211'
        url = dj_cache_url.parse(url)

        self.assertEqual(
            url['BACKEND'],
            'django.core.cache.backends.memcached.MemcachedCache')
        self.assertEqual(url['LOCATION'], '127.0.0.1:11211')
Ejemplo n.º 7
0
    def test_file_relative_parsing(self):
        self.skipTest("Not made")
        url = 'file:////tmp/foo'
        url = dj_cache_url.parse(url)

        self.assertEqual(
            url['BACKEND'],
            'django.core.cache.backends.filebased.FileBasedCache')
        self.assertEqual(url['LOCATION'], 'tmp/foo')
Ejemplo n.º 8
0
    def test_parse_timeout_setting(self):
        timeout = 600
        url = 'memcached://127.0.0.1:11211'
        url = dj_cache_url.parse(url, timeout=timeout)

        self.assertEqual(url['TIMEOUT'], timeout)
Ejemplo n.º 9
0
    def test_parse_engine_setting(self):
        backend = 'foo.BarBackend'
        url = 'memcached://127.0.0.1:11211'
        url = dj_cache_url.parse(url, backend)

        self.assertEqual(url['BACKEND'], backend)
Ejemplo n.º 10
0
    def test_redis_parsing(self):
        url = 'redis://127.0.0.1:6379/1'
        url = dj_cache_url.parse(url)

        self.assertEqual(url['BACKEND'], 'django_redis.cache.RedisCache')
        self.assertEqual(url['LOCATION'], 'redis://127.0.0.1:6379/1')
Ejemplo n.º 11
0
    def test_parse_key_function_setting(self):
        key_function = 42
        url = 'memcached://127.0.0.1:11211'
        url = dj_cache_url.parse(url, key_function=key_function)

        self.assertEqual(url['KEY_FUNCTION'], key_function)
Ejemplo n.º 12
0
    def test_parse_version_setting(self):
        version = 42
        url = 'memcached://127.0.0.1:11211'
        url = dj_cache_url.parse(url, version=version)

        self.assertEqual(url['VERSION'], version)
Ejemplo n.º 13
0
    def test_parse_key_prefix_setting(self):
        key_prefix = 'foo'
        url = 'memcached://127.0.0.1:11211'
        url = dj_cache_url.parse(url, key_prefix=key_prefix)

        self.assertEqual(url['KEY_PREFIX'], key_prefix)