def test_memcached_status_with_no_memcached_profiles(self): caches = { 'foo': {'BACKEND': 'django.core.cache.backends.db.DatabaseCache'} } setattr(settings, 'CACHES', caches) all_stats = memcached_status.check(request=None) assert len(all_stats) == 0
def test_memcached_with_different_cache_backends(self, mock_get_cache): backends = 'django.core.cache.backends' caches = { 'foo': { 'BACKEND': '{}.db.DatabaseCache'.format(backends) }, 'bar': { 'BACKEND': '{}.memcached.MemcachedCache'.format(backends) } } server = 'foo:11211' stats = { 'bytes': 1, 'limit_maxbytes': 10, 'get_misses': 10, 'cmd_get': 100, 'foo': 'bar' } mock_get_cache.return_value._cache.get_stats.return_value = ([(server, stats)]) setattr(settings, 'CACHES', caches) all_stats = memcached_status.check(request=None) assert len(all_stats) == 1 assert len(all_stats[0]['locations']) == 1 location = all_stats[0]['locations'][0] assert location['name'] == server assert location['details']['foo'] == 'bar'
def test_memcached_status(self, mock_get_cache, backend): caches = { 'foo': { 'BACKEND': 'django.core.cache.backends.memcached.{}'.format(backend) } } server = 'foo:11211' stats = { 'bytes': 1, 'limit_maxbytes': 10, 'get_misses': 10, 'cmd_get': 100, 'foo': 'bar' } mock_get_cache.return_value._cache.get_stats.return_value = [(server, stats)] setattr(settings, 'CACHES', caches) all_stats = memcached_status.check(request=None) assert len(all_stats) == 1 assert len(all_stats[0]['locations']) == 1 location = all_stats[0]['locations'][0] assert location['name'] == server assert location['summary']['load'] == 10 assert location['details']['foo'] == 'bar' assert len(location['details'].items()) == 5
def test_memcached_with_different_cache_backends(self, mock_get_cache): backends = 'django.core.cache.backends' caches = { 'foo': { 'BACKEND': '{}.db.DatabaseCache'.format(backends) }, 'bar': { 'BACKEND': '{}.memcached.MemcachedCache'.format(backends) } } server = 'foo:11211' stats = { 'bytes': 1, 'limit_maxbytes': 10, 'get_misses': 10, 'cmd_get': 100, 'foo': 'bar' } mock_get_cache.return_value._cache.get_stats.return_value = ([(server, stats)]) setattr(settings, 'CACHES', caches) all_stats = memcached_status.check(request=None) assert len(all_stats) == 1 assert len(all_stats[0]['locations']) == 1 location = all_stats[0]['locations'][0] assert location['name'] == server assert location['details']['foo'] == 'bar'
def test_memcached_status(self, mock_get_cache, backend): caches = { 'foo': { 'BACKEND': 'django.core.cache.backends.memcached.{}'.format(backend) } } server = 'foo:11211' stats = { 'bytes': 1, 'limit_maxbytes': 10, 'get_misses': 10, 'cmd_get': 100, 'foo': 'bar' } mock_get_cache.return_value._cache.get_stats.return_value = [(server, stats)] setattr(settings, 'CACHES', caches) all_stats = memcached_status.check(request=None) assert len(all_stats) == 1 assert len(all_stats[0]['locations']) == 1 location = all_stats[0]['locations'][0] assert location['name'] == server assert location['summary']['load'] == 10 assert location['details']['foo'] == 'bar' assert len(location['details'].items()) == 5
def test_memcached_status_with_no_memcached_profiles(self): caches = { 'foo': { 'BACKEND': 'django.core.cache.backends.db.DatabaseCache' } } setattr(settings, 'CACHES', caches) all_stats = memcached_status.check(request=None) assert len(all_stats) == 0
def test_memcached_status_with_no_profiles(self): setattr(settings, 'CACHES', dict()) all_stats = memcached_status.check(request=None) assert len(all_stats) == 0
def test_memcached_status_with_no_profiles(self): setattr(settings, 'CACHES', dict()) all_stats = memcached_status.check(request=None) assert len(all_stats) == 0