<commit_before>
try:
    # If relman-auto-nag is installed
    from auto_nag.bugzilla.utils import os
    from auto_nag.scripts.query_creator import (getTemplateValue, getReportURL,
                                                createQueriesList)
    import shutil
except:
    # If relman-auto-nag not installed, add project root directory into
    # PYTHONPATH
    import os
    import sys
    import inspect
    import shutil
    currentdir = os.path.dirname(os.path.abspath(
                                 inspect.getfile(inspect.currentframe())))
    parentdir = os.path.dirname(currentdir)
    sys.path.insert(0, parentdir)
    from auto_nag.scripts.query_creator import (getTemplateValue, getReportURL,
                                                createQueriesList)

class TestQueryCreator:
    def test_getTemplateValue(self):
        """
        Expecting a VERSION number
        """
        url = "https://wiki.mozilla.org/Template:BETA_VERSION"
        beta_version = getTemplateValue(url)
        assert type(int(beta_version)) is not type(int)

    def test_getReportURL(self):
        """
        Expecting proper URL with Bug numbers
        """
        url = 'https://wiki.mozilla.org/Template:CURRENT_CYCLE'
        cycle_span = getTemplateValue(url)
        unlanded_beta_url = getReportURL("approval-mozilla-beta",
                                         cycle_span)
        unlanded_aurora_url = getReportURL("approval-mozilla-aurora",
                                           cycle_span)
        unlanded_esr38_url = getReportURL("approval-mozilla-esr38",
                                          cycle_span)

        url = unlanded_beta_url.split('=')
        assert isinstance(int(url[1].split(',')[0]), (int))
        url = unlanded_aurora_url.split('=')
        assert isinstance(int(url[1].split(',')[0]), (int))
        url = unlanded_esr38_url.split('=')
        assert isinstance(int(url[1].split(',')[0]), (int))

    def test_createQueriesList(self):
        """
        Expecting list of queries
        """
        queries_dir = os.path.dirname(os.path.realpath(__file__)) + '/queries/'
        queries = createQueriesList(queries_dir, True)
        assert queries

    def tearDown(self):
        """
        Delete unnecessory folders
        """
        # createQueriesList creating this folder
        queries_dir = os.path.dirname(os.path.realpath(__file__)) + '/queries/'
        if os.path.isdir(queries_dir):
            shutil.rmtree(queries_dir)<commit_msg>Better code coverage in qurey_creator, method name changed for sequential test execution<commit_after>
from auto_nag.bugzilla.utils import os
from auto_nag.bugzilla.utils import get_project_root_path
from auto_nag.scripts.query_creator import (getTemplateValue, getReportURL,
                                            createQueriesList, cleanUp)
import shutil
import datetime

class TestQueryCreator:
    def setUp(self):
        self.queries_dir = get_project_root_path() + 'queries/'

    def test_1(self):
        """
        Tests for getTemplateValue,
        Expecting a VERSION number
        """
        url = "https://wiki.mozilla.org/Template:BETA_VERSION"
        beta_version = getTemplateValue(url)
        assert type(int(beta_version)) is not type(int)

    def test_2(self):
        """
        Tests for getReportURL
        Expecting proper URL with Bug numbers
        """
        url = 'https://wiki.mozilla.org/Template:CURRENT_CYCLE'
        cycle_span = getTemplateValue(url)
        unlanded_beta_url = getReportURL("approval-mozilla-beta",
                                         cycle_span)
        unlanded_aurora_url = getReportURL("approval-mozilla-aurora",
                                           cycle_span)
        unlanded_esr38_url = getReportURL("approval-mozilla-esr38",
                                          cycle_span)

        url = unlanded_beta_url.split('=')
        assert isinstance(int(url[1].split(',')[0]), (int))
        url = unlanded_aurora_url.split('=')
        assert isinstance(int(url[1].split(',')[0]), (int))
        url = unlanded_esr38_url.split('=')
        assert isinstance(int(url[1].split(',')[0]), (int))

    def test_3(self):
        """
        Tests for createQueriesList, weekday < 5 and > 0
        Expecting list of queries
        """
        queries = createQueriesList(self.queries_dir, 4, True)
        assert queries

    def test_4(self):
        """
        Tests for createQueriesList, weekday=3
        Expecting list of queries
        """
        queries = createQueriesList(self.queries_dir, 3, True)
        assert queries

    def test_5(self):
        """
        Tests for createQueriesList, weekday=0
        Expecting list of queries
        """
        queries = createQueriesList(self.queries_dir, 0, True)
        assert queries

    def test_6(self):
        """
        Tests for cleanUp
        Delete unnecessory folders
        """
        assert cleanUp(self.queries_dir)


{'fraction_non_alphanumeric': 0.09931918301962354, 'fraction_numerical': 0.007609130957148579, 'mean_word_length': 2.0986352357320097, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 19, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4608681', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1413, 'n_words': 287}