def test_update_job_trigger(self): # Setup Expected Response name_2 = 'name2-1052831874' display_name = 'displayName1615086568' description = 'description-1724546052' expected_response = { 'name': name_2, 'display_name': display_name, 'description': description } expected_response = dlp_pb2.JobTrigger(**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 name = client.project_job_trigger_path('[PROJECT]', '[JOB_TRIGGER]') response = client.update_job_trigger(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = dlp_pb2.UpdateJobTriggerRequest(name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_create_job_trigger(self): # Setup Expected Response name = 'name3373707' display_name = 'displayName1615086568' description = 'description-1724546052' expected_response = { 'name': name, 'display_name': display_name, 'description': description } expected_response = dlp_pb2.JobTrigger(**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.create_job_trigger(parent) assert expected_response == response assert len(channel.requests) == 1 expected_request = dlp_pb2.CreateJobTriggerRequest(parent=parent) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_job_trigger(self): # Setup Expected Response name_2 = "name2-1052831874" display_name = "displayName1615086568" description = "description-1724546052" expected_response = { "name": name_2, "display_name": display_name, "description": description, } expected_response = dlp_pb2.JobTrigger(**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 name = client.project_job_trigger_path("[PROJECT]", "[JOB_TRIGGER]") response = client.get_job_trigger(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = dlp_pb2.GetJobTriggerRequest(name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_job_trigger(self): # Setup Expected Response name_2 = 'name2-1052831874' display_name = 'displayName1615086568' description = 'description-1724546052' expected_response = { 'name': name_2, 'display_name': display_name, 'description': description } expected_response = dlp_pb2.JobTrigger(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = dlp_v2.DlpServiceClient(channel=channel) # Setup Request name = client.project_job_trigger_path('[PROJECT]', '[JOB_TRIGGER]') response = client.get_job_trigger(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = dlp_pb2.GetJobTriggerRequest(name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request