Exemplo n.º 1
0
 def test_rmv_works_correctly_single_thread(self):
     cacher = ConcurrentCacher(MemoryCacher(), {}, threading.Lock(),
                               threading.Condition())
     cacher.put("abc", "abcd")
     self.assertIn("abc", cacher)
     cacher.rmv("abc")
     self.assertNotIn("abc", cacher)
     cacher.rmv("abc")
Exemplo n.º 2
0
    def test_rmv_during_get_same_process_causes_exception(self):

        base_cacher = IterCacher()
        curr_cacher = ConcurrentCacher(base_cacher, {}, threading.Lock(),
                                       threading.Condition())

        curr_cacher.put(1, range(4))

        iter_1 = curr_cacher.get(1)
        next(iter_1)

        with self.assertRaises(CobaException):
            curr_cacher.rmv(1)
Exemplo n.º 3
0
    def test_rmv_during_get_same_process_with_release(self):

        base_cacher = IterCacher()
        curr_cacher = ConcurrentCacher(base_cacher, {}, threading.Lock(),
                                       threading.Condition())

        curr_cacher.put(1, range(4))
        try:
            iter_1 = curr_cacher.get(1)
            next(iter_1)
            raise Exception("Something unexpected went wrong while reading")
        except:
            curr_cacher.release(1)
            curr_cacher.rmv(1)