def test_purge_an_instance(self, logger, debug_mock, settings): purge_an_instance("http://NinaFox") self.assertTrue('CacheDebug: Delete cache keys related to pattern' in str(debug_mock.call_args_list)) self.assertEqual(retrieve(u"_@@_@@http://Charles@@xubiru##instance"), {}) self.assertEqual(retrieve(u"_@@_@@http://NinaFox@@class_uri=http://dog##instance"), None) self.assertEqual(retrieve(u"_@@_@@http://NinaFox@@a=1&b=2##instance"), None) self.assertEqual(retrieve(u"_@@_@@http://NinaFox@@abc##instance"), None)
def test_update_if_present_when_it_is_present(self): response = create("to_update_key", '{"key": "old value"}') self.assertTrue(response) response = retrieve("to_update_key") self.assertEqual(response, {"key": "old value"}) response = update_if_present("to_update_key", '{"key": "up-to-date value"}') self.assertTrue(response) response = retrieve("to_update_key") self.assertEqual(response["body"], u'{"key": "up-to-date value"}')
def test_update_if_present_when_it_is_present(self): response = create("to_update_key", '{"key": "old value"}') self.assertTrue(response) response = retrieve("to_update_key") self.assertEqual(response, {"key": "old value"}) response = update_if_present("to_update_key", '{"key": "up-to-date value"}') self.assertTrue(response) response = retrieve("to_update_key") self.assertEqual(response["body"], u'{"key": "up-to-date value"}')
def test_purge_an_instance(self, logger, debug_mock, settings): purge_an_instance("http://NinaFox") self.assertTrue('CacheDebug: Delete cache keys related to pattern' in str(debug_mock.call_args_list)) self.assertEqual(retrieve(u"_@@_@@http://Charles@@xubiru##instance"), {}) self.assertEqual( retrieve(u"_@@_@@http://NinaFox@@class_uri=http://dog##instance"), None) self.assertEqual(retrieve(u"_@@_@@http://NinaFox@@a=1&b=2##instance"), None) self.assertEqual(retrieve(u"_@@_@@http://NinaFox@@abc##instance"), None)
def test_200_with_miss(self, enable_cache): cached_value = retrieve("http://semantica.globo.com/person/@@http://semantica.globo.com/person/Gender##class") self.assertEqual(cached_value, None) response = self.fetch("/person/Gender/_schema", method='GET') self.assertEqual(response.code, 200) body = json.loads(response.body) self.assertIn("properties", body.keys()) self.assertTrue(response.headers.get('Last-Modified')) self.assertTrue(response.headers['X-Cache'].startswith('MISS from localhost')) cached_value = retrieve("http://semantica.globo.com/person/@@http://semantica.globo.com/person/Gender##class") self.assertTrue(cached_value)
def test_purge_all_instances(self, logger, info, debug, settings): purge_all_instances() self.assertEqual(retrieve("non_default_key"), {}) self.assertEqual(retrieve("_@@_@@inst_a##instance"), None) self.assertEqual(retrieve("_@@_@@inst_b@@a=1&b=2##instance"), None) self.assertEqual(retrieve("_##json_schema"), {}) self.assertEqual(retrieve("_##root"), {}) self.assertEqual(retrieve("some_graph@@some_instance##class"), {})
def test_purge_all_instances(self, logger, info, debug, settings): purge_all_instances() self.assertEqual(retrieve("non_default_key"), {}) self.assertEqual(retrieve("_@@_@@inst_a##instance"), None) self.assertEqual(retrieve("_@@_@@inst_b@@a=1&b=2##instance"), None) self.assertEqual(retrieve("_##json_schema"), {}) self.assertEqual(retrieve("_##root"), {}) self.assertEqual(retrieve("some_graph@@some_instance##class"), {})
def test_retrieve(self): response = retrieve("key_xubiru") self.assertEqual(response, {"key": "value"})
def test_retrieve_inexistent(self): response = retrieve("inexistent_key") self.assertEqual(response, None)
def test_retrieve(self): response = retrieve("key_xubiru") self.assertEqual(response, {"key": "value"})
def test_retrieve_inexistent(self): response = retrieve("inexistent_key") self.assertEqual(response, None)
def test_flushall_after_import_cache(self): cache.create('any_key', 1) self.assertEqual(cache.retrieve('any_key'), 1) cache.flushall() self.assertEqual(cache.keys('*'), [])
def test_flushall_after_import_cache(self): cache.create('any_key', 1) self.assertEqual(cache.retrieve('any_key'), 1) cache.flushall() self.assertEqual(cache.keys('*'), [])