Ejemplo n.º 1
0
    def test_set_calls_pool_request_with_correct_content_type(self):
        pool = mock.Mock(spec=riakcached.pools.Pool)
        pool.request.return_value = None, None, None
        pool.url = "http://127.0.0.1:8098"

        client = RiakClient("test_bucket", pool=pool)
        client.set("test", "value", content_type="application/test")
        self.assertTrue(pool.request.called)
        pool.request.assert_called_once_with(
            method="POST",
            url="http://127.0.0.1:8098/buckets/test_bucket/keys/test",
            body="value",
            headers={
                "Content-Type": "application/test",
            },
        )
Ejemplo n.º 2
0
    def test_set_calls_pool_request_with_correct_content_type(self):
        pool = mock.Mock(spec=riakcached.pools.Pool)
        pool.request.return_value = None, None, None
        pool.url = "http://127.0.0.1:8098"

        client = RiakClient("test_bucket", pool=pool)
        client.set("test", "value", content_type="application/test")
        self.assertTrue(pool.request.called)
        pool.request.assert_called_once_with(
            method="POST",
            url="http://127.0.0.1:8098/buckets/test_bucket/keys/test",
            body="value",
            headers={
                "Content-Type": "application/test",
            },
        )
Ejemplo n.º 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",
            },
        )
Ejemplo n.º 4
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",
            },
        )