def test_cache_delete(self): uris = ['i18n://[email protected]', 'i18n://[email protected]'] cache.set(uris[0], u'Foo') cache.set(uris[1], u'Bar') with self.assertCache(hits=2): cache.get_many(uris) cache.delete_many(uris) with self.assertCache(misses=2): cache.get_many(uris)
def test_cache_encoding(self): cio.set(self.uri, u'epost') cached_node = cache.get(self.uri) content = cached_node['content'] self.assertIsInstance(content, six.text_type) self.assertEqual(content, u'epost') cache.set('i18n://sv-se@label/email.txt#1', u'epost') nodes = cache.get_many((self.uri, self.uri)) self.assertDictEqual(nodes, {self.uri: {'uri': 'i18n://sv-se@label/email.txt#1', 'content': u'epost'}})
def test_cache_set(self): with self.assertRaises(URI.Invalid): cache.set('i18n://sv-se@foo', u'Bar') nodes = { 'i18n://[email protected]#1': u'Foo', 'i18n://[email protected]#2': u'Bar' } cache.set_many(nodes) with self.assertCache(calls=1, hits=2): result = cache.get_many(['i18n://sv-se@foo', 'i18n://sv-se@bar']) self.assertDictEqual(result, { 'i18n://sv-se@foo': {'uri': 'i18n://[email protected]#1', 'content': u'Foo'}, 'i18n://sv-se@bar': {'uri': 'i18n://[email protected]#2', 'content': u'Bar'} })
def test_cache_encoding(self): cio.set(self.uri, u'epost') cached_node = cache.get(self.uri) content = cached_node['content'] self.assertIsInstance(content, six.text_type) self.assertEqual(content, u'epost') cache.set('i18n://sv-se@label/email.txt#1', u'epost') nodes = cache.get_many((self.uri, self.uri)) self.assertDictEqual( nodes, { self.uri: { 'uri': 'i18n://sv-se@label/email.txt#1', 'content': u'epost' } })
def test_cache_set(self): with self.assertRaises(URI.Invalid): cache.set('i18n://sv-se@foo', u'Bar') nodes = { 'i18n://[email protected]#1': u'Foo', 'i18n://[email protected]#2': u'Bar' } cache.set_many(nodes) with self.assertCache(calls=1, hits=2): result = cache.get_many(['i18n://sv-se@foo', 'i18n://sv-se@bar']) self.assertDictEqual( result, { 'i18n://sv-se@foo': { 'uri': 'i18n://[email protected]#1', 'content': u'Foo' }, 'i18n://sv-se@bar': { 'uri': 'i18n://[email protected]#2', 'content': u'Bar' } })