<commit_before>"""
Tests of disco_acm
"""
from unittest import TestCase
from mock import MagicMock

from disco_aws_automation import DiscoACM
from disco_aws_automation.disco_acm import (
    CERT_SUMMARY_LIST_KEY,
    CERT_ARN_KEY,
    DOMAIN_NAME_KEY,
    CERT_ALT_NAMES_KEY,
    CERT_KEY
)

TEST_DOMAIN_NAME = 'test.example.com'
TEST_ALT_DOMAIN_NAME = 'test2.example.com'
TEST_DEEP_DOMAIN_NAME = 'a.deeper.test.example.com'
TEST_WILDCARD_DOMAIN_NAME = '*.example.com'
TEST_CERTIFICATE_ARN_ACM_EXACT = 'arn:aws:acm::123:exact'
TEST_CERTIFICATE_ARN_ACM_WILDCARD = 'arn:aws:acm::123:wildcard'
TEST_MULTI_CERT_ARN_ACM = 'arn:aws:acm::123:multi'
TEST_MULTI_DOMAIN_NAME = 'multi.foo.com'
TEST_MULTI_ALT_DOMAIN_NAME = 'foo.com'

TEST_CERT = {CERT_ARN_KEY: TEST_CERTIFICATE_ARN_ACM_EXACT, DOMAIN_NAME_KEY: TEST_DOMAIN_NAME}
TEST_WILDCARD_CERT = {CERT_ARN_KEY: TEST_CERTIFICATE_ARN_ACM_WILDCARD,
                      DOMAIN_NAME_KEY: TEST_WILDCARD_DOMAIN_NAME}
TEST_MULTI_CERT = {CERT_ARN_KEY: TEST_MULTI_CERT_ARN_ACM, DOMAIN_NAME_KEY: TEST_MULTI_DOMAIN_NAME}


class DiscoACMTests(TestCase):
    """Test disco_acm.py"""

    def setUp(self):
        self._acm = MagicMock()
        self.disco_acm = DiscoACM(self._acm)

        self._acm.list_certificates.return_value = {
            CERT_SUMMARY_LIST_KEY: [TEST_CERT, TEST_WILDCARD_CERT, TEST_MULTI_CERT]
        }

        def _describe_cert(CertificateArn):
            cert_data = {
                TEST_CERTIFICATE_ARN_ACM_WILDCARD: {
                    CERT_ARN_KEY: TEST_CERTIFICATE_ARN_ACM_WILDCARD,
                    CERT_ALT_NAMES_KEY: [TEST_WILDCARD_DOMAIN_NAME]
                },
                TEST_CERTIFICATE_ARN_ACM_EXACT: {
                    CERT_ARN_KEY: TEST_CERTIFICATE_ARN_ACM_EXACT,
                    CERT_ALT_NAMES_KEY: [TEST_DOMAIN_NAME]
                },
                TEST_MULTI_CERT_ARN_ACM: {
                    CERT_ARN_KEY: TEST_MULTI_CERT_ARN_ACM,
                    CERT_ALT_NAMES_KEY: [TEST_MULTI_DOMAIN_NAME, TEST_MULTI_ALT_DOMAIN_NAME]
                }
            }

            return {CERT_KEY: cert_data.get(CertificateArn)}<commit_msg>fix pylint check<commit_after>"""
Tests of disco_acm
"""
from unittest import TestCase
from mock import MagicMock

from disco_aws_automation import DiscoACM
from disco_aws_automation.disco_acm import (
    CERT_SUMMARY_LIST_KEY,
    CERT_ARN_KEY,
    DOMAIN_NAME_KEY,
    CERT_ALT_NAMES_KEY,
    CERT_KEY
)

TEST_DOMAIN_NAME = 'test.example.com'
TEST_ALT_DOMAIN_NAME = 'test2.example.com'
TEST_DEEP_DOMAIN_NAME = 'a.deeper.test.example.com'
TEST_WILDCARD_DOMAIN_NAME = '*.example.com'
TEST_CERTIFICATE_ARN_ACM_EXACT = 'arn:aws:acm::123:exact'
TEST_CERTIFICATE_ARN_ACM_WILDCARD = 'arn:aws:acm::123:wildcard'
TEST_MULTI_CERT_ARN_ACM = 'arn:aws:acm::123:multi'
TEST_MULTI_DOMAIN_NAME = 'multi.foo.com'
TEST_MULTI_ALT_DOMAIN_NAME = 'foo.com'

TEST_CERT = {CERT_ARN_KEY: TEST_CERTIFICATE_ARN_ACM_EXACT, DOMAIN_NAME_KEY: TEST_DOMAIN_NAME}
TEST_WILDCARD_CERT = {CERT_ARN_KEY: TEST_CERTIFICATE_ARN_ACM_WILDCARD,
                      DOMAIN_NAME_KEY: TEST_WILDCARD_DOMAIN_NAME}
TEST_MULTI_CERT = {CERT_ARN_KEY: TEST_MULTI_CERT_ARN_ACM, DOMAIN_NAME_KEY: TEST_MULTI_DOMAIN_NAME}


class DiscoACMTests(TestCase):
    """Test disco_acm.py"""

    def setUp(self):
        self._acm = MagicMock()
        self.disco_acm = DiscoACM(self._acm)

        self._acm.list_certificates.return_value = {
            CERT_SUMMARY_LIST_KEY: [TEST_CERT, TEST_WILDCARD_CERT, TEST_MULTI_CERT]
        }

        # pylint: disable=invalid-name
        def _describe_cert(CertificateArn):
            cert_data = {
                TEST_CERTIFICATE_ARN_ACM_WILDCARD: {
                    CERT_ARN_KEY: TEST_CERTIFICATE_ARN_ACM_WILDCARD,
                    CERT_ALT_NAMES_KEY: [TEST_WILDCARD_DOMAIN_NAME]
                },
                TEST_CERTIFICATE_ARN_ACM_EXACT: {
                    CERT_ARN_KEY: TEST_CERTIFICATE_ARN_ACM_EXACT,
                    CERT_ALT_NAMES_KEY: [TEST_DOMAIN_NAME]
                },
                TEST_MULTI_CERT_ARN_ACM: {
                    CERT_ARN_KEY: TEST_MULTI_CERT_ARN_ACM,
                    CERT_ALT_NAMES_KEY: [TEST_MULTI_DOMAIN_NAME, TEST_MULTI_ALT_DOMAIN_NAME]
                }
            }

            return {CERT_KEY: cert_data.get(CertificateArn)}
{'fraction_non_alphanumeric': 0.07603152526657395, 'fraction_numerical': 0.004636068613815485, 'mean_word_length': 3.193391642371234, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1179578', 'n_tokens_mistral': 1819, 'n_tokens_neox': 1654, 'n_words': 191}