def test_get_deidentify_template(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.DeidentifyTemplate(**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.organization_deidentify_template_path(
            '[ORGANIZATION]', '[DEIDENTIFY_TEMPLATE]')

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

        assert len(channel.requests) == 1
        expected_request = dlp_pb2.GetDeidentifyTemplateRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Exemplo n.º 2
0
    def test_update_deidentify_template(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.DeidentifyTemplate(**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.organization_deidentify_template_path(
            "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]"
        )

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

        assert len(channel.requests) == 1
        expected_request = dlp_pb2.UpdateDeidentifyTemplateRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_create_deidentify_template(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.DeidentifyTemplate(**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.organization_path('[ORGANIZATION]')

        response = client.create_deidentify_template(parent)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = dlp_pb2.CreateDeidentifyTemplateRequest(
            parent=parent)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Exemplo n.º 4
0
    def test_update_deidentify_template(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.DeidentifyTemplate(**expected_response)

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

        # Setup Request
        name = client.organization_deidentify_template_path(
            '[ORGANIZATION]', '[DEIDENTIFY_TEMPLATE]')

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

        assert len(channel.requests) == 1
        expected_request = dlp_pb2.UpdateDeidentifyTemplateRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request