def test_get_dlp_job(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        job_trigger_name = 'jobTriggerName1819490804'
        expected_response = {
            'name': name_2,
            'job_trigger_name': job_trigger_name
        }
        expected_response = dlp_pb2.DlpJob(**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.dlp_job_path('[PROJECT]', '[DLP_JOB]')

        response = client.get_dlp_job(name)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = dlp_pb2.GetDlpJobRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_create_dlp_job(self):
        # Setup Expected Response
        name = 'name3373707'
        job_trigger_name = 'jobTriggerName1819490804'
        expected_response = {
            'name': name,
            'job_trigger_name': job_trigger_name
        }
        expected_response = dlp_pb2.DlpJob(**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.create_dlp_job(parent)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = dlp_pb2.CreateDlpJobRequest(parent=parent)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Exemple #3
0
    def test_get_dlp_job(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        job_trigger_name = 'jobTriggerName1819490804'
        expected_response = {
            'name': name_2,
            'job_trigger_name': job_trigger_name
        }
        expected_response = dlp_pb2.DlpJob(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        client = dlp_v2.DlpServiceClient(channel=channel)

        # Setup Request
        name = client.dlp_job_path('[PROJECT]', '[DLP_JOB]')

        response = client.get_dlp_job(name)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = dlp_pb2.GetDlpJobRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Exemple #4
0
    def test_create_dlp_job(self):
        # Setup Expected Response
        name = 'name3373707'
        job_trigger_name = 'jobTriggerName1819490804'
        expected_response = {
            'name': name,
            'job_trigger_name': job_trigger_name
        }
        expected_response = dlp_pb2.DlpJob(**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_dlp_job(parent)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = dlp_pb2.CreateDlpJobRequest(parent=parent)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request