<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

from fab.config.deployer import DeployerConfig
from fab.helpers.virtualenv import VirtualEnv
from fab.tasks.virtualenv import RebuildRSRVirtualEnv


class RebuildRSRVirtualEnvTest(mox.MoxTestBase):

    def setUp(self):
        super(RebuildRSRVirtualEnvTest, self).setUp()
        self.mock_deployer_config = self.mox.CreateMock(DeployerConfig)
        self.mock_virtualenv = self.mox.CreateMock(VirtualEnv)

        self.rebuild_virtualenv_task = RebuildRSRVirtualEnv(self.mock_deployer_config, self.mock_virtualenv)

    def test_can_rebuild_rsr_virtualenv(self):
        """fab.tests.tasks.RebuildRSRVirtualEnvTest  Can rebuild an RSR virtualenv"""

        pip_log_file = "/some/log/path/pip.log"
        pip_requirements_home = "/path/to/pip/requirements"
        rsr_requirements_path = os.path.join(pip_requirements_home, RebuildRSRVirtualEnv.RSR_REQUIREMENTS_FILE)

        self.mock_deployer_config.pip_install_log_file = pip_log_file
        self.mock_deployer_config.pip_requirements_home = pip_requirements_home
        self.mock_virtualenv.create_empty_virtualenv(pip_log_file)<commit_msg>[#6699037] Added test for expected task name in RebuildRSRVirtualEnvTest.<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

from fab.config.deployer import DeployerConfig
from fab.helpers.virtualenv import VirtualEnv
from fab.tasks.virtualenv import RebuildRSRVirtualEnv


class RebuildRSRVirtualEnvTest(mox.MoxTestBase):

    def setUp(self):
        super(RebuildRSRVirtualEnvTest, self).setUp()
        self.mock_deployer_config = self.mox.CreateMock(DeployerConfig)
        self.mock_virtualenv = self.mox.CreateMock(VirtualEnv)

        self.rebuild_virtualenv_task = RebuildRSRVirtualEnv(self.mock_deployer_config, self.mock_virtualenv)

    def test_has_expected_task_name(self):
        """fab.tests.tasks.RebuildRSRVirtualEnvTest  Has expected task name"""

        self.assertEqual("rebuild_rsr_virtualenv", RebuildRSRVirtualEnv.name)

    def test_can_rebuild_rsr_virtualenv(self):
        """fab.tests.tasks.RebuildRSRVirtualEnvTest  Can rebuild an RSR virtualenv"""

        pip_log_file = "/some/log/path/pip.log"
        pip_requirements_home = "/path/to/pip/requirements"
        rsr_requirements_path = os.path.join(pip_requirements_home, RebuildRSRVirtualEnv.RSR_REQUIREMENTS_FILE)

        self.mock_deployer_config.pip_install_log_file = pip_log_file
        self.mock_deployer_config.pip_requirements_home = pip_requirements_home
        self.mock_virtualenv.create_empty_virtualenv(pip_log_file)
{'fraction_non_alphanumeric': 0.07594544327340359, 'fraction_numerical': 0.0021698698078115313, 'mean_word_length': 4.535162950257289, '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': '417807', 'n_tokens_mistral': 1054, 'n_tokens_neox': 1006, 'n_words': 202}