Exemplo n.º 1
0
    def test_read_blob(self):
        responses = [
            data_provider_pb2.ReadBlobResponse(data=b"hello wo"),
            data_provider_pb2.ReadBlobResponse(data=b"rld"),
        ]
        self.stub.ReadBlob.return_value = responses

        actual = self.provider.read_blob(self.ctx, blob_key="myblob")
        expected = b"hello world"
        self.assertEqual(actual, expected)

        req = data_provider_pb2.ReadBlobRequest()
        req.blob_key = "myblob"
        self.stub.ReadBlob.assert_called_once_with(req)
Exemplo n.º 2
0
 def fake_handler(req):
     del req  # unused
     yield data_provider_pb2.ReadBlobResponse(data=b"hello wo"),
     raise _grpc_error(grpc.StatusCode.NOT_FOUND, "it ran away!")