def test_cache_hit(self, cache_set_mock, cache_get_mock, template_tags_mock): """Should not call other methods on cache hit.""" cache_get_mock.return_value = set(['active']) self.assertTrue(template_is_active('the/dude', 'de')) cache_get_mock.assert_called_once_with('template_tag_set:the/dude:de') self.assertFalse(template_tags_mock.called) self.assertFalse(cache_set_mock.called)
def test_cache_hit(self, cache_set_mock, cache_get_mock, lang_active_mock, parse_template_mock): """Should not call other methods on cache hit.""" cache_get_mock.return_value = True self.assertTrue(template_is_active("the/dude", "de")) cache_get_mock.assert_called_once_with("template_active:de:the/dude") self.assertFalse(lang_active_mock.called) self.assertFalse(parse_template_mock.called) self.assertFalse(cache_set_mock.called)
def test_cache_hit(self, cache_set_mock, cache_get_mock, lang_active_mock, parse_template_mock): """Should not call other methods on cache hit.""" cache_get_mock.return_value = True self.assertTrue(template_is_active('the/dude', 'de')) cache_get_mock.assert_called_once_with('template_active:de:the/dude') self.assertFalse(lang_active_mock.called) self.assertFalse(parse_template_mock.called) self.assertFalse(cache_set_mock.called)
def test_cache_miss(self, cache_set_mock, cache_get_mock, template_tags_mock): """Should check the files and set the cache on cache miss.""" cache_get_mock.return_value = None template_tags_mock.return_value = set(['active']) self.assertTrue(template_is_active('the/dude', 'de')) cache_key = 'template_tag_set:the/dude:de' cache_get_mock.assert_called_once_with(cache_key) self.assertTrue(template_tags_mock.called) cache_set_mock.assert_called_once_with(cache_key, set(['active']))
def test_cache_miss(self, cache_set_mock, cache_get_mock, template_tags_mock): """Should check the files and set the cache on cache miss.""" cache_get_mock.return_value = None template_tags_mock.return_value = set(['active']) self.assertTrue(template_is_active('the/dude', 'de')) cache_key = 'template_tag_set:the/dude:de' cache_get_mock.assert_called_once_with(cache_key) self.assertTrue(template_tags_mock.called) cache_set_mock.assert_called_once_with(cache_key, set(['active']), settings.DOTLANG_CACHE)
def test_cache_miss(self, cache_set_mock, cache_get_mock, lang_active_mock, parse_template_mock): """Should check the files and set the cache on cache miss.""" cache_get_mock.return_value = None lang_active_mock.return_value = True self.assertTrue(template_is_active("the/dude", "de")) cache_key = "template_active:de:the/dude" cache_get_mock.assert_called_once_with(cache_key) self.assertTrue(lang_active_mock.called) self.assertFalse(parse_template_mock.called) cache_set_mock.assert_called_once_with(cache_key, True, settings.DOTLANG_CACHE)
def test_cache_miss(self, cache_set_mock, cache_get_mock, lang_active_mock, parse_template_mock): """Should check the files and set the cache on cache miss.""" cache_get_mock.return_value = None lang_active_mock.return_value = True self.assertTrue(template_is_active('the/dude', 'de')) cache_key = 'template_active:de:the/dude' cache_get_mock.assert_called_once_with(cache_key) self.assertTrue(lang_active_mock.called) self.assertFalse(parse_template_mock.called) cache_set_mock.assert_called_once_with(cache_key, True, settings.DOTLANG_CACHE)