<commit_before>#!/usr/bin/env python

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


import mox, os

from testing.helpers.execution import TestSuiteLoader, TestRunner

import fab.tests.templates.config_loaders_template
from config_loaders import UserCredentialsLoader

from fab.config.values.standard import CIDeploymentHostConfig
from fab.tasks.database.backup import BackupRSRDatabase
from fab.tasks.environment.python.systempackages import UpdateSystemPythonPackages
from fab.tasks.runner import TaskParameters, TaskRunner
from fab.verifiers.config import ConfigFileVerifier


class StubbedTaskRunner(TaskRunner):

    fake_exit_code = 0

    def _execute(self, command_with_parameters):
        self.executed_command_with_parameters = command_with_parameters
        return self.fake_exit_code


class TaskRunnerTest(mox.MoxTestBase):

    def setUp(self):
        super(TaskRunnerTest, self).setUp()

        self.user_credentials = UserCredentialsLoader.load()
        self.deployment_host_config = CIDeploymentHostConfig.for_test()

        self.task_runner = StubbedTaskRunner(self.user_credentials, self.deployment_host_config)

    def test_can_create_taskrunner_instance(self):
        """fab.tests.tasks.task_runner_test  Can create a TaskRunner instance"""
<commit_msg>[#23361761] Added test for task parameter options.<commit_after>#!/usr/bin/env python

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


import mox, os

from testing.helpers.execution import TestSuiteLoader, TestRunner

import fab.tests.templates.config_loaders_template
from config_loaders import UserCredentialsLoader

from fab.config.values.standard import CIDeploymentHostConfig
from fab.tasks.database.backup import BackupRSRDatabase
from fab.tasks.environment.python.systempackages import UpdateSystemPythonPackages
from fab.tasks.runner import TaskParameters, TaskRunner
from fab.verifiers.config import ConfigFileVerifier


class StubbedTaskRunner(TaskRunner):

    fake_exit_code = 0

    def _execute(self, command_with_parameters):
        self.executed_command_with_parameters = command_with_parameters
        return self.fake_exit_code


class TaskRunnerTest(mox.MoxTestBase):

    def setUp(self):
        super(TaskRunnerTest, self).setUp()

        self.user_credentials = UserCredentialsLoader.load()
        self.deployment_host_config = CIDeploymentHostConfig.for_test()

        self.task_runner = StubbedTaskRunner(self.user_credentials, self.deployment_host_config)

    def test_has_expected_task_parameter_options(self):
        """fab.tests.tasks.task_runner_test  Has expected task parameter options"""

        self.assertEqual('', TaskParameters.NONE)
        self.assertEqual('host_controller_mode=remote', TaskParameters.REMOTE_HOST_CONTROLLER_MODE)

    def test_can_create_taskrunner_instance(self):
        """fab.tests.tasks.task_runner_test  Can create a TaskRunner instance"""

{'fraction_non_alphanumeric': 0.06968325791855204, 'fraction_numerical': 0.0030165912518853697, 'mean_word_length': 4.879432624113475, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '526856', 'n_tokens_mistral': 955, 'n_tokens_neox': 923, 'n_words': 232}