def test_partition_read(self): # Setup Expected Response expected_response = {} expected_response = spanner_pb2.PartitionResponse(**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 = spanner_v1.SpannerClient() # Setup Request session = client.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]") table = "table110115790" key_set = {} response = client.partition_read(session, table, key_set) assert expected_response == response assert len(channel.requests) == 1 expected_request = spanner_pb2.PartitionReadRequest(session=session, table=table, key_set=key_set) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_partition_query(self): # Setup Expected Response expected_response = {} expected_response = spanner_pb2.PartitionResponse(**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 = spanner_v1.SpannerClient() # Setup Request session = client.session_path('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]') sql = 'sql114126' response = client.partition_query(session, sql) assert expected_response == response assert len(channel.requests) == 1 expected_request = spanner_pb2.PartitionQueryRequest(session=session, sql=sql) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_partition_query(self): # Setup Expected Response expected_response = {} expected_response = spanner_pb2.PartitionResponse(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = spanner_v1.SpannerClient(channel=channel) # Setup Request session = client.session_path('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]') sql = 'sql114126' response = client.partition_query(session, sql) assert expected_response == response assert len(channel.requests) == 1 expected_request = spanner_pb2.PartitionQueryRequest(session=session, sql=sql) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_partition_read(self): # Setup Expected Response expected_response = {} expected_response = spanner_pb2.PartitionResponse(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = spanner_v1.SpannerClient(channel=channel) # Setup Request session = client.session_path('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]') table = 'table110115790' key_set = {} response = client.partition_read(session, table, key_set) assert expected_response == response assert len(channel.requests) == 1 expected_request = spanner_pb2.PartitionReadRequest(session=session, table=table, key_set=key_set) actual_request = channel.requests[0][1] assert expected_request == actual_request