def test_main_with_valid_args(self):
        check_function_calls = {
            'execute_branch_cut_gets_called': False,
            'release_version': None,
            'hotfix_number': None
        }
        expected_check_function_calls = {
            'execute_branch_cut_gets_called': True,
            'release_version': '1.2.3',
            'hotfix_number': 1
        }

        def mock_execute_branch_cut(release_version, hotfix_number):
            check_function_calls['release_version'] = release_version
            check_function_calls['hotfix_number'] = hotfix_number
            check_function_calls['execute_branch_cut_gets_called'] = True

        args_swap = self.swap(sys, 'argv', [
            'cut_release_or_hotfix_branch.py', '--release_version=1.2.3',
            '--hotfix_number=1'
        ])
        branch_cut_swap = self.swap(cut_release_or_hotfix_branch,
                                    'execute_branch_cut',
                                    mock_execute_branch_cut)
        with args_swap, branch_cut_swap:
            cut_release_or_hotfix_branch.main()
        self.assertEqual(check_function_calls, expected_check_function_calls)
示例#2
0
def cut_release_branch():
    """Calls the cut_release_or_hotfix_branch script to cut a release branch.

    Raises:
        AssertionError. The version entered is invalid.
    """
    common.open_new_tab_in_browser_if_possible(
        'https://github.com/oppia/oppia/releases')
    python_utils.PRINT(
        'Enter the new version for the release.\n'
        'If major changes occurred since the last release, or if '
        'the third version is a 9, increment the minor version '
        '(e.g. 2.5.3 -> 2.6.0 or 2.5.9 -> 2.6.0)\n'
        'Otherwise, increment the third version number '
        '(e.g. 2.5.3 -> 2.5.4)\n')
    release_version = python_utils.INPUT()
    assert re.match(r'\d+\.\d+\.\d+$', release_version)
    cut_release_or_hotfix_branch.main(
        args=['--release_version=%s' % release_version])
 def test_missing_release_version(self):
     args_swap = self.swap(sys, 'argv', ['cut_release_or_hotfix_branch.py'])
     with args_swap, self.assertRaisesRegexp(
             Exception,
             'ERROR: A "release_version" arg must be specified.'):
         cut_release_or_hotfix_branch.main()