summaryrefslogtreecommitdiff
path: root/tests/cache
diff options
context:
space:
mode:
authorNick Pope <nick.pope@flightdataservices.com>2020-08-15 21:34:32 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-09-02 08:51:17 +0200
commita6291394256aa758d74eec9ce0cfae8aea6475f2 (patch)
tree4fab7beaca627ae1448400ad3fe72b6fe08d7e7e /tests/cache
parent0bf627f0b2f868cdcc53ac12cc7f390901d4b83d (diff)
downloaddjango-a6291394256aa758d74eec9ce0cfae8aea6475f2.tar.gz
Refs #29887, Refs #24212 -- Added servers configuration hook for memcached backends.
The servers property can be overridden to allow memcached backends to alter the server configuration prior to it being passed to instantiate the client. This allows avoidance of documentation for per-backend differences, e.g. stripping the 'unix:' prefix for pylibmc.
Diffstat (limited to 'tests/cache')
-rw-r--r--tests/cache/tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/cache/tests.py b/tests/cache/tests.py
index 3aa01ccced..93f0d87ecb 100644
--- a/tests/cache/tests.py
+++ b/tests/cache/tests.py
@@ -1441,6 +1441,18 @@ class PyLibMCCacheTests(BaseMemcachedTests, TestCase):
self.assertTrue(cache._cache.binary)
self.assertEqual(cache._cache.behaviors['tcp_nodelay'], int(True))
+ def test_pylibmc_client_servers(self):
+ backend = self.base_params['BACKEND']
+ tests = [
+ ('unix:/run/memcached/socket', '/run/memcached/socket'),
+ ('/run/memcached/socket', '/run/memcached/socket'),
+ ('127.0.0.1:11211', '127.0.0.1:11211'),
+ ]
+ for location, expected in tests:
+ settings = {'default': {'BACKEND': backend, 'LOCATION': location}}
+ with self.subTest(location), self.settings(CACHES=settings):
+ self.assertEqual(cache.client_servers, [expected])
+
@override_settings(CACHES=caches_setting_for_tests(
BACKEND='django.core.cache.backends.filebased.FileBasedCache',