Beispiel #1
0
def _check_cache(cache_name):
    key = 'django-watchman-{}'.format(uuid.uuid4())
    value = 'django-watchman-{}'.format(uuid.uuid4())

    cache = utils.get_cache(cache_name)

    cache.set(key, value)
    cache.get(key)
    cache.delete(key)
    return {cache_name: {"ok": True}}
    def test_get_cache(self, cache_mock):
        cache_key = 'my_cache'
        cache_value = 'i am a cache'
        cache = {cache_key: cache_value}

        def getitem(cache_name):
            return cache[cache_name]

        cache_mock.caches.__getitem__.side_effect = getitem

        result = get_cache(cache_key)

        self.assertEqual(result, cache_value)
Beispiel #3
0
 def test_get_cache_less_than_django_17(self, get_cache_mock):
     get_cache('foo')
     get_cache_mock.assert_called_once_with('foo')
Beispiel #4
0
 def test_get_cache_django_17_or_greater(self, get_cache_mock):
     get_cache('foo')
     get_cache_mock.__getitem__.called_once_with('foo')
    def test_get_cache_less_than_django_17(self, django_mock, get_cache_mock):
        django_mock.VERSION = (1, 6, 6, 'final', 0)

        get_cache('foo')

        get_cache_mock.assert_called_once_with('foo')
 def test_get_cache_less_than_django_17(self, get_cache_mock):
     get_cache('foo')
     get_cache_mock.assert_called_once_with('foo')
 def test_get_cache_django_17_or_greater(self, get_cache_mock):
     get_cache('foo')
     get_cache_mock.__getitem__.called_once_with('foo')