def test_client_adds_serializer(self):
        serializer = mock.Mock()

        client = RiakClient("test_bucket", pool=mock.Mock(spec=riakcached.pools.Pool))
        client.add_serializer("application/test", serializer)
        self.assertEqual(client._serializers["application/test"], serializer)
        client.serialize("test", "application/test")
        serializer.assert_called()
Exemple #2
0
    def test_client_adds_serializer(self):
        serializer = mock.Mock()

        client = RiakClient("test_bucket",
                            pool=mock.Mock(spec=riakcached.pools.Pool))
        client.add_serializer("application/test", serializer)
        self.assertEqual(client._serializers["application/test"], serializer)
        client.serialize("test", "application/test")
        serializer.assert_called()
Exemple #3
0
    def test_set_uses_serializer(self):
        pool = mock.Mock(spec=riakcached.pools.Pool)
        pool.request.return_value = 204, "", {}
        pool.url = "http://127.0.0.1:8098"

        def serializer(data):
            return "serialized"

        client = RiakClient("test_bucket", pool=pool)
        client.add_serializer("application/test", serializer)
        client.set("test", "value", content_type="application/test")
        pool.request.assert_called_once_with(
            method="POST",
            url="http://127.0.0.1:8098/buckets/test_bucket/keys/test",
            body="serialized",
            headers={
                "Content-Type": "application/test",
            },
        )
    def test_set_uses_serializer(self):
        pool = mock.Mock(spec=riakcached.pools.Pool)
        pool.request.return_value = 204, "", {}
        pool.url = "http://127.0.0.1:8098"

        def serializer(data):
            return "serialized"

        client = RiakClient("test_bucket", pool=pool)
        client.add_serializer("application/test", serializer)
        client.set("test", "value", content_type="application/test")
        pool.request.assert_called_once_with(
            method="POST",
            url="http://127.0.0.1:8098/buckets/test_bucket/keys/test",
            body="serialized",
            headers={
                "Content-Type": "application/test",
            },
        )