def test_redact_image(self): # Setup Expected Response redacted_image = b'28' extracted_text = 'extractedText998260012' expected_response = { 'redacted_image': redacted_image, 'extracted_text': extracted_text } expected_response = dlp_pb2.RedactImageResponse(**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 = dlp_v2.DlpServiceClient() # Setup Request parent = client.project_path('[PROJECT]') response = client.redact_image(parent) assert expected_response == response assert len(channel.requests) == 1 expected_request = dlp_pb2.RedactImageRequest(parent=parent) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_redact_image(self): # Setup Expected Response redacted_image = b'28' extracted_text = 'extractedText998260012' expected_response = { 'redacted_image': redacted_image, 'extracted_text': extracted_text } expected_response = dlp_pb2.RedactImageResponse(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = dlp_v2.DlpServiceClient(channel=channel) # Setup Request parent = client.project_path('[PROJECT]') response = client.redact_image(parent) assert expected_response == response assert len(channel.requests) == 1 expected_request = dlp_pb2.RedactImageRequest(parent=parent) actual_request = channel.requests[0][1] assert expected_request == actual_request