<commit_before>""" unit test """
import os
import time

from bzt.engine import ScenarioExecutor
from bzt.utils import BetterDict, EXE_SUFFIX
from tests import BZTestCase, __dir__, local_paths_config
from tests.mocks import EngineEmul


class TestEngine(BZTestCase):
    def setUp(self):
        super(TestEngine, self).setUp()
        self.obj = EngineEmul()
        self.paths = local_paths_config()

    def test_delay(self):
        configs = [__dir__() + "/../bzt/10-base.json",
                   __dir__() + "/yaml/delay_0.yml",

                   self.paths]
        self.obj.configure(configs)
        self.obj.create_artifacts_dir(configs)
        self.obj.prepare()
        start0 = time.time()
        self.obj.run()
        finish0 = time.time()
        self.obj.post_process()

        configs = [__dir__() + "/../bzt/10-base.json",
                   __dir__() + "/yaml/delay_1.yml",
                   self.paths]
        self.obj.configure(configs)
        self.obj.create_artifacts_dir(configs)
        self.obj.prepare()
        start1 = time.time()
        self.obj.run()
        finish1 = time.time()
        self.obj.post_process()

        self.assertTrue(finish1 - start1 > finish0 - start0)

    def test_requests(self):
        configs = [
            __dir__() + "/../bzt/10-base.json",
            __dir__() + "/json/get-post.json",
            __dir__() + "/json/reporting.json",
            self.paths
        ]
        self.obj.configure(configs)
        self.obj.create_artifacts_dir(configs)
        self.obj.prepare()
        self.obj.run()
        self.obj.post_process()

    def test_double_exec(self):
        configs = [
            __dir__() + "/../bzt/10-base.json",
            __dir__() + "/yaml/triple.yml",
            __dir__() + "/json/reporting.json",
            self.paths
        ]
        self.obj.configure(configs)
        self.obj.create_artifacts_dir(configs)
        self.obj.prepare()
        self.obj.run()
        self.obj.post_process()

    def test_unknown_module(self):
        configs = [
            __dir__() + "/../bzt/10-base.json",
            __dir__() + "/json/gatling.json",
            self.paths
        ]
        self.obj.configure(configs)
        self.obj.create_artifacts_dir(configs)
        self.obj.config["provisioning"] = "unknown"
        self.obj.config["modules"]["unknown"] = BetterDict()

        try:
            self.obj.prepare()
            self.fail()
        except ValueError:
            pass


class TestScenarioExecutor(BZTestCase):
    def setUp(self):
        super(TestScenarioExecutor, self).setUp()
        self.engine = EngineEmul()
        self.executor = ScenarioExecutor()
        self.executor.engine = self.engine

    def test_creates_hostaliases_file(self):
        self.engine.config.merge({
            "settings": {
                "hostaliases": {
                    "demo": "blazedemo.com"
                }
            }
        })
<commit_msg>Revert artifacts dir creating in engine tests<commit_after>""" unit test """
import os
import time

from bzt.engine import ScenarioExecutor
from bzt.utils import BetterDict, EXE_SUFFIX
from tests import BZTestCase, __dir__, local_paths_config
from tests.mocks import EngineEmul


class TestEngine(BZTestCase):
    def setUp(self):
        super(TestEngine, self).setUp()
        self.obj = EngineEmul()
        self.paths = local_paths_config()

    def test_delay(self):
        configs = [__dir__() + "/../bzt/10-base.json",
                   __dir__() + "/yaml/delay_0.yml",

                   self.paths]
        self.obj.configure(configs)
        self.obj.prepare()
        start0 = time.time()
        self.obj.run()
        finish0 = time.time()
        self.obj.post_process()

        configs = [__dir__() + "/../bzt/10-base.json",
                   __dir__() + "/yaml/delay_1.yml",
                   self.paths]
        self.obj.configure(configs)
        self.obj.prepare()
        start1 = time.time()
        self.obj.run()
        finish1 = time.time()
        self.obj.post_process()

        self.assertTrue(finish1 - start1 > finish0 - start0)

    def test_requests(self):
        configs = [
            __dir__() + "/../bzt/10-base.json",
            __dir__() + "/json/get-post.json",
            __dir__() + "/json/reporting.json",
            self.paths
        ]
        self.obj.configure(configs)
        self.obj.prepare()
        self.obj.run()
        self.obj.post_process()

    def test_double_exec(self):
        configs = [
            __dir__() + "/../bzt/10-base.json",
            __dir__() + "/yaml/triple.yml",
            __dir__() + "/json/reporting.json",
            self.paths
        ]
        self.obj.configure(configs)
        self.obj.prepare()
        self.obj.run()
        self.obj.post_process()

    def test_unknown_module(self):
        configs = [
            __dir__() + "/../bzt/10-base.json",
            __dir__() + "/json/gatling.json",
            self.paths
        ]
        self.obj.configure(configs)
        self.obj.config["provisioning"] = "unknown"
        self.obj.config["modules"]["unknown"] = BetterDict()

        try:
            self.obj.prepare()
            self.fail()
        except ValueError:
            pass


class TestScenarioExecutor(BZTestCase):
    def setUp(self):
        super(TestScenarioExecutor, self).setUp()
        self.engine = EngineEmul()
        self.executor = ScenarioExecutor()
        self.executor.engine = self.engine

    def test_creates_hostaliases_file(self):
        self.engine.config.merge({
            "settings": {
                "hostaliases": {
                    "demo": "blazedemo.com"
                }
            }
        })

{'fraction_non_alphanumeric': 0.13174908264896035, 'fraction_numerical': 0.006989341254586755, 'mean_word_length': 1.7466410748560461, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 5, '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': '3178392', 'n_tokens_mistral': 1792, 'n_tokens_neox': 1740, 'n_words': 283}