def test_get(self): imc_1 = IMCache() imc_2 = IMCache() combined = CombinedCache(imc_1, imc_2) imc_1.put('a', 1) self.assertEqual(combined.get('a'), 1) imc_2.put('b', 1) self.assertEqual(combined.get('b'), 1) imc_1.put('c', 1) imc_2.put('c', 2) self.assertEqual(combined.get('c'), 1)
def test_get_update_closer_cache(self): imc_1 = IMCache() imc_2 = IMCache() combined = CombinedCache(imc_1, imc_2) imc_2.put('b', 1) with self.assertRaises(imc_1.CacheMissException): imc_1.get('b') self.assertEqual(combined.get('b'), 1) self.assertEqual(imc_1.get('b'), 1)