예제 #1
0
    def test_cleanup_on_windows(self):
        def mock_is_windows_os():
            return True

        subprocess_swap = self.swap(run_e2e_tests, 'SUBPROCESSES', [])

        google_app_engine_path = '%s/' % (common.GOOGLE_APP_ENGINE_HOME)
        webdriver_download_path = '%s/downloads' % (
            run_e2e_tests.WEBDRIVER_HOME_PATH)
        process_pattern = [('.*%s.*' % re.escape(google_app_engine_path), ),
                           ('.*%s.*' % re.escape(webdriver_download_path), )]
        expected_pattern = process_pattern[:]
        expected_pattern[1] = (
            '.*%s.*' % re.escape(os.path.abspath(webdriver_download_path)), )

        def mock_kill_process_based_on_regex(unused_regex):
            return

        swap_kill_process = self.swap_with_checks(
            common,
            'kill_processes_based_on_regex',
            mock_kill_process_based_on_regex,
            expected_args=expected_pattern)
        swap_is_windows = self.swap_with_checks(common, 'is_windows_os',
                                                mock_is_windows_os)
        with swap_kill_process, subprocess_swap, swap_is_windows:
            run_e2e_tests.cleanup()
예제 #2
0
    def test_cleanup_when_no_subprocess(self):
        def mock_is_windows_os():
            return False

        subprocess_swap = self.swap(run_e2e_tests, 'SUBPROCESSES', [])

        dev_appserver_path = '%s/dev_appserver.py' % (
            common.GOOGLE_APP_ENGINE_HOME)
        webdriver_download_path = '%s/downloads' % (
            run_e2e_tests.WEBDRIVER_HOME_PATH)
        process_pattern = [('.*%s.*' % re.escape(dev_appserver_path), ),
                           ('.*%s.*' % re.escape(webdriver_download_path), )]

        def mock_kill_process_based_on_regex(unused_regex):
            return

        swap_kill_process = self.swap_with_checks(
            common,
            'kill_processes_based_on_regex',
            mock_kill_process_based_on_regex,
            expected_args=process_pattern)
        swap_is_windows = self.swap_with_checks(common, 'is_windows_os',
                                                mock_is_windows_os)
        with swap_kill_process, subprocess_swap, swap_is_windows:
            run_e2e_tests.cleanup()
예제 #3
0
    def test_cleanup_when_no_subprocess(self):

        def mock_kill_process_based_on_regex(unused_regex):
            return

        def mock_is_windows_os():
            return False

        def mock_set_constants_to_default():
            return

        subprocess_swap = self.swap(run_e2e_tests, 'SUBPROCESSES', [])

        google_app_engine_path = '%s/' % (
            common.GOOGLE_APP_ENGINE_HOME)
        webdriver_download_path = '%s/selenium' % (
            run_e2e_tests.WEBDRIVER_HOME_PATH)
        process_pattern = [
            ('.*%s.*' % re.escape(google_app_engine_path),),
            ('.*%s.*' % re.escape(webdriver_download_path),)
        ]

        swap_kill_process = self.swap_with_checks(
            common, 'kill_processes_based_on_regex',
            mock_kill_process_based_on_regex,
            expected_args=process_pattern)
        swap_is_windows = self.swap_with_checks(
            common, 'is_windows_os', mock_is_windows_os)
        swap_set_constants_to_default = self.swap_with_checks(
            build, 'set_constants_to_default', mock_set_constants_to_default)
        with swap_kill_process, subprocess_swap, swap_is_windows:
            with swap_set_constants_to_default:
                run_e2e_tests.cleanup()
예제 #4
0
    def test_cleanup_when_subprocesses_exist(self):
        def mock_kill_process_based_on_regex(unused_regex):
            mock_kill_process_based_on_regex.called_times += 1
            return True

        mock_kill_process_based_on_regex.called_times = 0

        mock_processes = [MockProcessClass(), MockProcessClass()]
        subprocess_swap = self.swap(run_e2e_tests, 'SUBPROCESSES',
                                    mock_processes)
        swap_kill_process = self.swap_with_checks(
            common, 'kill_processes_based_on_regex',
            mock_kill_process_based_on_regex)
        with subprocess_swap, swap_kill_process:
            run_e2e_tests.cleanup()
        self.assertEqual(mock_kill_process_based_on_regex.called_times,
                         len(mock_processes))