<commit_before># tests for dns_parser.py

import pytest
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)) + '/../')

import dnstest


class TestDNSrules:
    """
    Test DNS tests, using stubbed name resolution methods that return static values.

    The code in this class checks the logic of dnstest.py's test_*_name methods, which take
    input describing the change, and query nameservers to check current prod and staging status.
    """

    def stub_resolve_name(query, to_server, default_domain, to_port=53):
        """
        stub method

        return a dict that looks like the return value from dnstest.resolve_name
        but either returns one of a hard-coded group of dicts, or an error.
        """

        #return {'answer': a.answers[0]}
        return {'status': a.header['status']}

    # stub
    dnstest.resolve_name = stub_resolve_name

    def stub_lookup_reverse(name, to_server, to_port=53):
        """
        stub method

        return a dict that looks like the return value from dnstest.lookup_reverse
        but either returns one of a hard-coded group of dicts, or an error.
        """
        #return {'answer': a.answers[0]}
        return {'status': a.header['status']}

    # stub
    dnstest.lookup_reverse = stub_lookup_reverse
<commit_msg>adding base of first test of dns checks<commit_after># tests for dns_parser.py

import pytest
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)) + '/../')

import dnstest


class DNScheck:
    """
    Test DNS checks, using stubbed name resolution methods that return static values.

    The code in this class checks the logic of dnstest.py's test_*_name methods, which take
    input describing the change, and query nameservers to check current prod and staging status.
    """

    def stub_resolve_name(query, to_server, default_domain, to_port=53):
        """
        stub method

        return a dict that looks like the return value from dnstest.resolve_name
        but either returns one of a hard-coded group of dicts, or an error.
        """

        #return {'answer': a.answers[0]}
        return {'status': a.header['status']}

    # stub
    dnstest.resolve_name = stub_resolve_name

    def stub_lookup_reverse(name, to_server, to_port=53):
        """
        stub method

        return a dict that looks like the return value from dnstest.lookup_reverse
        but either returns one of a hard-coded group of dicts, or an error.
        """
        #return {'answer': a.answers[0]}
        return {'status': a.header['status']}

    # stub
    dnstest.lookup_reverse = stub_lookup_reverse

    def test_dns_add(self):
        """
        Test checks for adding a record to DNS
        """
        

{'fraction_non_alphanumeric': 0.08753602305475504, 'fraction_numerical': 0.005043227665706052, 'mean_word_length': 2.752702702702703, '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': '2811045', 'n_tokens_mistral': 842, 'n_tokens_neox': 804, 'n_words': 287}