<commit_before>from unittest import TestCase
from mock import Mock, MagicMock, patch
from subprocess import PIPE
from cloudshell.cm.ansible.domain.ansible_command_executor import AnsibleCommandExecutor
from helpers import mock_enter_exit_self


class TestAnsibleCommandExecutor(TestCase):

    def setUp(self):
        self.process_mock = Mock()
        self.stdout_mock = mock_enter_exit_self()
        self.convert_mock = Mock()
        self.sleep_mock = Mock()
        self.output_parser_mock = Mock()
        self.output_writer_mock = Mock()

        self.popen_patcher = patch('cloudshell.cm.ansible.domain.ansible_command_executor.Popen')
        self.stdout_patcher = patch('cloudshell.cm.ansible.domain.ansible_command_executor.StdoutAccumulator')
        self.convert_patcher = patch('cloudshell.cm.ansible.domain.ansible_command_executor.UnixToHtmlColorConverter.convert')
        self.sleep_patcher = patch('cloudshell.cm.ansible.domain.ansible_command_executor.time.sleep')

        self.popen_patcher.start().return_value = self.process_mock
        self.stdout_patcher.start().return_value = self.stdout_mock
        self.convert_mock = self.convert_patcher.start()
        self.sleep_mock = self.sleep_patcher.start()

        self.convert_mock.side_effect = (lambda x: x)
        self.sleep_mock.side_effect = (lambda x: 0)

        self.executor = AnsibleCommandExecutor(self.output_parser_mock)

    def tearDown(self):
        self.popen_patcher.stop()
        self.stdout_mock.stop()
        self.convert_mock.stop()
        self.sleep_mock.stop()

    def test_run_prcess_with_corrent_command_line(self):
        with patch('cloudshell.cm.ansible.domain.ansible_command_executor.Popen') as popen:
            self.executor.execute_playbook('playbook1','inventory1','-arg1 -args2',Mock(),Mock())<commit_msg>Fixed patcher<commit_after>from unittest import TestCase
from mock import Mock, MagicMock, patch
from subprocess import PIPE
from cloudshell.cm.ansible.domain.ansible_command_executor import AnsibleCommandExecutor
from helpers import mock_enter_exit_self


class TestAnsibleCommandExecutor(TestCase):

    def setUp(self):
        self.process_mock = Mock()
        self.stdout_mock = mock_enter_exit_self()
        self.convert_mock = Mock()
        self.sleep_mock = Mock()
        self.output_parser_mock = Mock()
        self.output_writer_mock = Mock()

        self.popen_patcher = patch('cloudshell.cm.ansible.domain.ansible_command_executor.Popen')
        self.stdout_patcher = patch('cloudshell.cm.ansible.domain.ansible_command_executor.StdoutAccumulator')
        self.convert_patcher = patch('cloudshell.cm.ansible.domain.ansible_command_executor.UnixToHtmlColorConverter.convert')
        self.sleep_patcher = patch('cloudshell.cm.ansible.domain.ansible_command_executor.time.sleep')

        self.popen_patcher.start().return_value = self.process_mock
        self.stdout_patcher.start().return_value = self.stdout_mock
        self.convert_mock = self.convert_patcher.start()
        self.sleep_mock = self.sleep_patcher.start()

        self.convert_mock.side_effect = (lambda x: x)
        self.sleep_mock.side_effect = (lambda x: 0)

        self.executor = AnsibleCommandExecutor(self.output_parser_mock)

    def tearDown(self):
        self.popen_patcher.stop()
        self.stdout_patcher.stop()
        self.convert_patcher.stop()
        self.sleep_patcher.stop()

    def test_run_prcess_with_corrent_command_line(self):
        with patch('cloudshell.cm.ansible.domain.ansible_command_executor.Popen') as popen:
            self.executor.execute_playbook('playbook1','inventory1','-arg1 -args2',Mock(),Mock())
{'fraction_non_alphanumeric': 0.09828009828009827, 'fraction_numerical': 0.00273000273000273, 'mean_word_length': 3.859416445623342, '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': '6072770', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1110, 'n_words': 156}