def testBasic(self): c = LocalSyncCache(id="test1") c["key1"] = "value1" self.assertEqual(c, {'key1': 'value1'}) cache.set("test1", time.time()) c.check_state() self.assertEqual(c, {}) cache_information = LocalSyncCache.get_cache_information() self.assertEqual(len(cache_information), 1)
def testBasic(self): c = LocalSyncCache(id="test1") c["key1"] = "value1" assert_pformat_equal(c, {"key1": "value1"}) cache.set("test1", time.time()) c.check_state() assert_pformat_equal(c, {}) cache_information = LocalSyncCache.get_cache_information() assert_pformat_equal(len(cache_information), 1)
def testMulti(self): assert_pformat_equal(len(LocalSyncCache.CACHES), 0) c1 = LocalSyncCache(id="test1") assert_pformat_equal(len(LocalSyncCache.CACHES), 1) c2 = LocalSyncCache(id="test1", unique_ids=False) assert_pformat_equal(len(LocalSyncCache.CACHES), 2) c1["c1"] = "foo" c2["c2"] = "bar" assert_pformat_equal(c1, {"c1": "foo"}) assert_pformat_equal(c2, {"c2": "bar"}) c1.check_state() c2.check_state() assert_pformat_equal(c1, {"c1": "foo"}) assert_pformat_equal(c2, {"c2": "bar"}) c1.clear() assert_pformat_equal(c1, {}) # In a "new request" all the same caches should be cleared c2.check_state() assert_pformat_equal(c2, {}) cache_information = LocalSyncCache.get_cache_information() assert_pformat_equal(len(cache_information), 2)
def testMulti(self): self.assertEqual(len(LocalSyncCache.CACHES), 0) c1 = LocalSyncCache(id="test1") self.assertEqual(len(LocalSyncCache.CACHES), 1) c2 = LocalSyncCache(id="test1", unique_ids=False) self.assertEqual(len(LocalSyncCache.CACHES), 2) c1["c1"] = "foo" c2["c2"] = "bar" self.assertEqual(c1, {'c1': 'foo'}) self.assertEqual(c2, {'c2': 'bar'}) c1.check_state() c2.check_state() self.assertEqual(c1, {'c1': 'foo'}) self.assertEqual(c2, {'c2': 'bar'}) c1.clear() self.assertEqual(c1, {}) # In a "new request" all the same caches should be cleared c2.check_state() self.assertEqual(c2, {}) cache_information = LocalSyncCache.get_cache_information() self.assertEqual(len(cache_information), 2)