Example #1
0
 def setUp(self):
     self.mem = FakeMemStore()
     self.cache = MemCachedCollection(self.mem, "animals")
Example #2
0
class Test(unittest.TestCase):
    def setUp(self):
        self.mem = FakeMemStore()
        self.cache = MemCachedCollection(self.mem, "animals")

    def test_write_cache(self):
        self.cache.set("timon", "pumba", 2)
        self.assertEqual(self.cache.get("timon"), "pumba")

    def test_delete_cache(self):
        self.cache.set("timon", "pumba")
        self.cache.delete("timon")
        self.assertEqual(self.cache.get("timon"), None)

    def test_get_inexistent_element(self):
        self.assertEqual(self.cache.get("timon"), None)

    def test_parameters_ok(self):
        self.mem.set = Mock()
        self.cache.set("timon", "pumba", 1.2)
        self.mem.set.assert_called_once_with("animals@timon", "pumba", time=1)

        self.mem.set = Mock()
        self.cache.set("timon2", "pumba2")
        self.mem.set.assert_called_once_with("animals@timon2", "pumba2", time=0)
Example #3
0
class Test(unittest.TestCase):
    def setUp(self):
        self.mem = FakeMemStore()
        self.cache = MemCachedCollection(self.mem, "animals")

    def test_write_cache(self):
        self.cache.set("timon", "pumba", 2)
        self.assertEqual(self.cache.get("timon"), "pumba")

    def test_delete_cache(self):
        self.cache.set("timon", "pumba")
        self.cache.delete("timon")
        self.assertEqual(self.cache.get("timon"), None)

    def test_get_inexistent_element(self):
        self.assertEqual(self.cache.get("timon"), None)

    def test_parameters_ok(self):
        self.mem.set = Mock()
        self.cache.set("timon", "pumba", 1.2)
        self.mem.set.assert_called_once_with("animals@timon", "pumba", time=1)

        self.mem.set = Mock()
        self.cache.set("timon2", "pumba2")
        self.mem.set.assert_called_once_with("animals@timon2",
                                             "pumba2",
                                             time=0)
Example #4
0
 def setUp(self):
     self.mem = FakeMemStore()
     self.cache = MemCachedCollection(self.mem, "animals")
Example #5
0
 def __init__(self, store, cache_client):
     self.store = store
     self.cache_client = cache_client
     self.ip_mc_collection = MemCachedCollection(cache_client, IP_ACCESSES)