def test_client_adds_deserializer(self): deserializer = mock.Mock() client = RiakClient("test_bucket", pool=mock.Mock(spec=riakcached.pools.Pool)) client.add_deserializer("application/test", deserializer) self.assertEqual(client._deserializers["application/test"], deserializer) client.deserialize("test", "application/test") deserializer.assert_called()
def test_get_uses_deserializer(self): pool = mock.Mock(spec=riakcached.pools.Pool) pool.request.return_value = 200, "some data", {"content-type": "application/test"} pool.url = "http://127.0.0.1:8098" def deserializer(data): return "deserialized" client = RiakClient("test_bucket", pool=pool) client.add_deserializer("application/test", deserializer) result = client.get("test") self.assertEqual("deserialized", result)
def test_get_uses_deserializer(self): pool = mock.Mock(spec=riakcached.pools.Pool) pool.request.return_value = 200, "some data", { "content-type": "application/test" } pool.url = "http://127.0.0.1:8098" def deserializer(data): return "deserialized" client = RiakClient("test_bucket", pool=pool) client.add_deserializer("application/test", deserializer) result = client.get("test") self.assertEqual("deserialized", result)