def test_cut_release_branch_with_incorrect_version(self):
        check_function_calls = {
            'open_new_tab_in_browser_if_possible_is_called': False,
            'check_call_is_called': False
        }
        expected_check_function_calls = {
            'open_new_tab_in_browser_if_possible_is_called': True,
            'check_call_is_called': False
        }
        def mock_open_tab(unused_url):
            check_function_calls[
                'open_new_tab_in_browser_if_possible_is_called'] = True
        def mock_check_call(unused_cmd_tokens):
            check_function_calls['check_call_is_called'] = True
        def mock_input():
            return 'invalid'

        open_tab_swap = self.swap(
            common, 'open_new_tab_in_browser_if_possible',
            mock_open_tab)
        check_call_swap = self.swap(
            subprocess, 'check_call', mock_check_call)
        input_swap = self.swap(
            python_utils, 'INPUT', mock_input)
        with open_tab_swap, check_call_swap, input_swap:
            with self.assertRaises(AssertionError):
                initial_release_prep.cut_release_branch()
        self.assertEqual(check_function_calls, expected_check_function_calls)
Пример #2
0
    def test_cut_release_branch_with_incorrect_version(self):
        check_function_calls = {
            'open_new_tab_in_browser_if_possible_is_called': False,
            'execute_branch_cut_is_called': False
        }
        expected_check_function_calls = {
            'open_new_tab_in_browser_if_possible_is_called': True,
            'execute_branch_cut_is_called': False
        }

        def mock_open_tab(unused_url):
            check_function_calls[
                'open_new_tab_in_browser_if_possible_is_called'] = True

        def mock_execute_branch_cut(unused_target_version,
                                    unused_hotfix_number):
            check_function_calls['execute_branch_cut_is_called'] = True

        def mock_input():
            return 'invalid'

        open_tab_swap = self.swap(common,
                                  'open_new_tab_in_browser_if_possible',
                                  mock_open_tab)
        branch_cut_swap = self.swap(cut_release_or_hotfix_branch,
                                    'execute_branch_cut',
                                    mock_execute_branch_cut)
        input_swap = self.swap(python_utils, 'INPUT', mock_input)
        with open_tab_swap, branch_cut_swap, input_swap:
            with self.assertRaisesRegexp(
                    AssertionError, 'The release version entered is invalid.'):
                initial_release_prep.cut_release_branch()
        self.assertEqual(check_function_calls, expected_check_function_calls)