def test_check_and_mutate_row(self): # Setup Expected Response predicate_matched = True expected_response = {"predicate_matched": predicate_matched} expected_response = bigtable_pb2.CheckAndMutateRowResponse(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = bigtable_v2.BigtableClient() # Setup Request table_name = client.table_path("[PROJECT]", "[INSTANCE]", "[TABLE]") row_key = b"122" response = client.check_and_mutate_row(table_name, row_key) assert expected_response == response assert len(channel.requests) == 1 expected_request = bigtable_pb2.CheckAndMutateRowRequest( table_name=table_name, row_key=row_key ) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_check_and_mutate_row(self): # Setup Expected Response predicate_matched = True expected_response = {'predicate_matched': predicate_matched} expected_response = bigtable_pb2.CheckAndMutateRowResponse( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = bigtable_v2.BigtableClient(channel=channel) # Setup Request table_name = client.table_path('[PROJECT]', '[INSTANCE]', '[TABLE]') row_key = b'122' response = client.check_and_mutate_row(table_name, row_key) assert expected_response == response assert len(channel.requests) == 1 expected_request = bigtable_pb2.CheckAndMutateRowRequest( table_name=table_name, row_key=row_key) actual_request = channel.requests[0][1] assert expected_request == actual_request
def _CheckAndMutateRowResponsePB(*args, **kw): from google.cloud.bigtable_v2.proto import (bigtable_pb2 as messages_v2_pb2) return messages_v2_pb2.CheckAndMutateRowResponse(*args, **kw)