def test_missing_release_summary_file(self):
        def mock_get_organization(unused_self, unused_name):
            return github.Organization.Organization(
                requester='', headers='', attributes={}, completed='')
        def mock_check_prs_for_current_release_are_released(unused_repo):
            pass
        def mock_get_repo(unused_self, unused_repo_name):
            return self.mock_repo

        get_org_swap = self.swap(
            github.Github, 'get_organization', mock_get_organization)
        get_repo_swap = self.swap(github.Github, 'get_repo', mock_get_repo)
        get_org_repo_swap = self.swap(
            github.Organization.Organization, 'get_repo', mock_get_repo)
        check_prs_swap = self.swap(
            common, 'check_prs_for_current_release_are_released',
            mock_check_prs_for_current_release_are_released)
        release_summary_swap = self.swap(
            constants.release_constants, 'RELEASE_SUMMARY_FILEPATH',
            'invalid.md')
        with self.branch_name_swap, release_summary_swap:
            with self.args_swap, self.getpass_swap:
                with get_org_swap, get_repo_swap, get_org_repo_swap:
                    with check_prs_swap, self.assertRaisesRegexp(
                        Exception, (
                            'Release summary file invalid.md is missing. '
                            'Please re-run this script.')):
                        update_changelog_and_credits.main()
 def test_missing_github_username(self):
     args_swap = self.swap(sys, 'argv', ['update_changelog_and_credits.py'])
     with self.branch_name_swap, self.release_summary_swap, args_swap:
         with self.assertRaisesRegexp(
                 Exception,
             ('No GitHub username provided. Please re-run the script '
              'specifying a username using --github_username='******'<Your username>')):
             update_changelog_and_credits.main()
Exemple #3
0
 def test_missing_release_summary_file(self):
     release_summary_swap = self.swap(release_constants,
                                      'RELEASE_SUMMARY_FILEPATH',
                                      'invalid.md')
     with self.main_swap, self.branch_name_swap, release_summary_swap:
         with self.args_swap, self.getpass_swap, self.assertRaisesRegexp(
                 Exception, ('Release summary file invalid.md is missing. '
                             'Please re-run this script.')):
             update_changelog_and_credits.main()
 def test_invalid_branch_name(self):
     def mock_get_current_branch_name():
         return 'invalid'
     branch_name_swap = self.swap(
         common, 'get_current_branch_name', mock_get_current_branch_name)
     with branch_name_swap, self.assertRaisesRegexp(
         Exception, (
             'This script should only be run from the latest release '
             'branch.')):
         update_changelog_and_credits.main()
 def test_missing_personal_access_token(self):
     def mock_getpass(prompt):  # pylint: disable=unused-argument
         return None
     getpass_swap = self.swap(getpass, 'getpass', mock_getpass)
     with self.branch_name_swap, self.release_summary_swap, self.args_swap:
         with getpass_swap, self.assertRaisesRegexp(
             Exception, (
                 'No personal access token provided, please set up a '
                 'personal access token at https://github.com/settings/'
                 'tokens and re-run the script')):
             update_changelog_and_credits.main()
    def test_function_calls(self):
        check_function_calls = {
            'check_blocking_bug_issue_count_gets_called': False,
            'check_prs_for_current_release_are_released_gets_called': False,
            'remove_updates_and_delete_branch_gets_called': False,
            'update_changelog_gets_called': False,
            'update_authors_gets_called': False,
            'update_contributors_gets_called': False,
            'update_developer_names_gets_called': False,
            'get_release_summary_lines_gets_called': False,
            'create_branch_gets_called': False,
            'open_new_tab_in_browser_if_possible_gets_called': False,
            'update_package_json_gets_called': False
        }
        expected_check_function_calls = {
            'check_blocking_bug_issue_count_gets_called': True,
            'check_prs_for_current_release_are_released_gets_called': True,
            'remove_updates_and_delete_branch_gets_called': True,
            'update_changelog_gets_called': True,
            'update_authors_gets_called': True,
            'update_contributors_gets_called': True,
            'update_developer_names_gets_called': True,
            'get_release_summary_lines_gets_called': True,
            'create_branch_gets_called': True,
            'open_new_tab_in_browser_if_possible_gets_called': True,
            'update_package_json_gets_called': True
        }

        def mock_get_organization(unused_self, unused_name):
            return github.Organization.Organization(requester='',
                                                    headers='',
                                                    attributes={},
                                                    completed='')

        def mock_check_blocking_bug_issue_count(unused_repo):
            check_function_calls[
                'check_blocking_bug_issue_count_gets_called'] = True

        def mock_check_prs_for_current_release_are_released(unused_repo):
            check_function_calls[
                'check_prs_for_current_release_are_released_gets_called'] = True

        def mock_remove_updates_and_delete_branch(unused_repo_fork,
                                                  unused_target_branch):
            check_function_calls[
                'remove_updates_and_delete_branch_gets_called'] = True

        def mock_update_changelog(unused_branch_name,
                                  unused_release_summary_lines,
                                  unused_current_release_version_number):
            check_function_calls['update_changelog_gets_called'] = True

        def mock_update_authors(unused_release_summary_lines):
            check_function_calls['update_authors_gets_called'] = True

        def mock_update_contributors(unused_release_summary_lines):
            check_function_calls['update_contributors_gets_called'] = True

        def mock_update_developer_names(unused_release_summary_lines):
            check_function_calls['update_developer_names_gets_called'] = True

        def mock_get_release_summary_lines():
            check_function_calls[
                'get_release_summary_lines_gets_called'] = True

        def mock_create_branch(unused_repo, unused_repo_fork,
                               unused_target_branch, unused_github_username,
                               unused_current_release_version_number):
            check_function_calls['create_branch_gets_called'] = True

        def mock_input():
            return 'y'

        def mock_get_repo(unused_self, unused_repo_name):
            return self.mock_repo

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

        def mock_update_package_json():
            check_function_calls['update_package_json_gets_called'] = True

        get_org_swap = self.swap(github.Github, 'get_organization',
                                 mock_get_organization)
        blocking_bug_swap = self.swap(common, 'check_blocking_bug_issue_count',
                                      mock_check_blocking_bug_issue_count)
        check_prs_swap = self.swap(
            common, 'check_prs_for_current_release_are_released',
            mock_check_prs_for_current_release_are_released)
        remove_updates_swap = self.swap(update_changelog_and_credits,
                                        'remove_updates_and_delete_branch',
                                        mock_remove_updates_and_delete_branch)
        update_changelog_swap = self.swap(update_changelog_and_credits,
                                          'update_changelog',
                                          mock_update_changelog)
        update_authors_swap = self.swap(update_changelog_and_credits,
                                        'update_authors', mock_update_authors)
        update_contributors_swap = self.swap(update_changelog_and_credits,
                                             'update_contributors',
                                             mock_update_contributors)
        update_developer_names_swap = self.swap(update_changelog_and_credits,
                                                'update_developer_names',
                                                mock_update_developer_names)
        get_lines_swap = self.swap(update_changelog_and_credits,
                                   'get_release_summary_lines',
                                   mock_get_release_summary_lines)
        create_branch_swap = self.swap(update_changelog_and_credits,
                                       'create_branch', mock_create_branch)
        input_swap = self.swap(python_utils, 'INPUT', mock_input)
        get_repo_swap = self.swap(github.Github, 'get_repo', mock_get_repo)
        get_org_repo_swap = self.swap(github.Organization.Organization,
                                      'get_repo', mock_get_repo)
        open_tab_swap = self.swap(common,
                                  'open_new_tab_in_browser_if_possible',
                                  mock_open_tab)
        update_swap = self.swap(update_changelog_and_credits,
                                'update_package_json',
                                mock_update_package_json)

        with self.branch_name_swap, self.release_summary_swap, self.args_swap:
            with self.getpass_swap, input_swap, check_prs_swap:
                with remove_updates_swap, update_authors_swap, open_tab_swap:
                    with update_changelog_swap, update_contributors_swap:
                        with update_developer_names_swap, get_lines_swap:
                            with create_branch_swap, get_repo_swap:
                                with blocking_bug_swap, get_org_swap:
                                    with get_org_repo_swap, update_swap:
                                        update_changelog_and_credits.main()

        self.assertEqual(check_function_calls, expected_check_function_calls)
Exemple #7
0
    def test_function_calls(self):
        check_function_calls = {
            'check_prs_for_current_release_are_released_gets_called': False,
            'remove_updates_and_delete_branch_gets_called': False,
            'update_changelog_gets_called': False,
            'update_authors_gets_called': False,
            'update_contributors_gets_called': False,
            'update_developer_names_gets_called': False,
            'get_release_summary_lines_gets_called': False,
            'create_branch_gets_called': False,
            'update_package_json_gets_called': False,
            'inform_server_errors_team_gets_called': False,
        }
        expected_check_function_calls = {
            'check_prs_for_current_release_are_released_gets_called': True,
            'remove_updates_and_delete_branch_gets_called': True,
            'update_changelog_gets_called': True,
            'update_authors_gets_called': True,
            'update_contributors_gets_called': True,
            'update_developer_names_gets_called': True,
            'get_release_summary_lines_gets_called': True,
            'create_branch_gets_called': True,
            'update_package_json_gets_called': True,
            'inform_server_errors_team_gets_called': True,
        }
        def mock_get_organization(unused_self, unused_name):
            return github.Organization.Organization(
                requester='', headers='', attributes={}, completed='')
        def mock_check_prs_for_current_release_are_released(unused_repo):
            check_function_calls[
                'check_prs_for_current_release_are_released_gets_called'] = True
        def mock_remove_updates_and_delete_branch(
                unused_repo_fork, unused_target_branch):
            check_function_calls[
                'remove_updates_and_delete_branch_gets_called'] = True
        def mock_update_changelog(
                unused_branch_name, unused_release_summary_lines,
                unused_current_release_version_number):
            check_function_calls['update_changelog_gets_called'] = True
        def mock_update_authors(unused_release_summary_lines):
            check_function_calls['update_authors_gets_called'] = True
        def mock_update_contributors(unused_release_summary_lines):
            check_function_calls['update_contributors_gets_called'] = True
        def mock_update_developer_names(unused_release_summary_lines):
            check_function_calls['update_developer_names_gets_called'] = True
        def mock_get_release_summary_lines():
            check_function_calls['get_release_summary_lines_gets_called'] = True
        def mock_create_branch(
                unused_repo, unused_repo_fork, unused_target_branch,
                unused_github_username, unused_current_release_version_number):
            check_function_calls['create_branch_gets_called'] = True
        def mock_inform_server_errors_team(
                unused_release_rota_url, unused_server_error_playbook_url
            ):
            check_function_calls['inform_server_errors_team_gets_called'] = True
        def mock_input():
            return 'y'
        def mock_get_repo(unused_self, unused_repo_name):
            return self.mock_repo
        def mock_update_version_in_config_files():
            check_function_calls['update_package_json_gets_called'] = True

        get_org_swap = self.swap(
            github.Github, 'get_organization', mock_get_organization)
        check_prs_swap = self.swap(
            common, 'check_prs_for_current_release_are_released',
            mock_check_prs_for_current_release_are_released)
        remove_updates_swap = self.swap(
            update_changelog_and_credits, 'remove_updates_and_delete_branch',
            mock_remove_updates_and_delete_branch)
        update_changelog_swap = self.swap(
            update_changelog_and_credits, 'update_changelog',
            mock_update_changelog)
        update_authors_swap = self.swap(
            update_changelog_and_credits, 'update_authors',
            mock_update_authors)
        update_contributors_swap = self.swap(
            update_changelog_and_credits, 'update_contributors',
            mock_update_contributors)
        update_developer_names_swap = self.swap(
            update_changelog_and_credits, 'update_developer_names',
            mock_update_developer_names)
        get_lines_swap = self.swap(
            update_changelog_and_credits, 'get_release_summary_lines',
            mock_get_release_summary_lines)
        create_branch_swap = self.swap(
            update_changelog_and_credits, 'create_branch', mock_create_branch)
        inform_server_errors_team_swap = self.swap(
            update_changelog_and_credits, 'inform_server_errors_team',
            mock_inform_server_errors_team)
        input_swap = self.swap(builtins, 'input', mock_input)
        get_repo_swap = self.swap(github.Github, 'get_repo', mock_get_repo)
        get_org_repo_swap = self.swap(
            github.Organization.Organization, 'get_repo', mock_get_repo)
        update_swap = self.swap(
            update_changelog_and_credits, 'update_version_in_config_files',
            mock_update_version_in_config_files)

        with self.branch_name_swap, self.release_summary_swap, self.args_swap:
            with self.getpass_swap, input_swap, check_prs_swap:
                with remove_updates_swap, update_authors_swap:
                    with update_changelog_swap, update_contributors_swap:
                        with update_developer_names_swap, get_lines_swap:
                            with create_branch_swap, get_repo_swap, update_swap:
                                with get_org_swap, get_org_repo_swap:
                                    with inform_server_errors_team_swap:
                                        update_changelog_and_credits.main()

        self.assertEqual(check_function_calls, expected_check_function_calls)
Exemple #8
0
    def test_function_calls(self):
        check_function_calls = {
            'remove_updates_and_delete_branch_gets_called': False,
            'update_changelog_gets_called': False,
            'update_authors_gets_called': False,
            'update_contributors_gets_called': False,
            'update_developer_names_gets_called': False,
            'check_ordering_of_sections_gets_called': False,
            'create_branch_gets_called': False,
            'open_new_tab_in_browser_if_possible_gets_called': False
        }
        expected_check_function_calls = {
            'remove_updates_and_delete_branch_gets_called': True,
            'update_changelog_gets_called': True,
            'update_authors_gets_called': True,
            'update_contributors_gets_called': True,
            'update_developer_names_gets_called': True,
            'check_ordering_of_sections_gets_called': True,
            'create_branch_gets_called': True,
            'open_new_tab_in_browser_if_possible_gets_called': True
        }

        def mock_remove_updates_and_delete_branch(unused_repo_fork,
                                                  unused_target_branch):
            check_function_calls[
                'remove_updates_and_delete_branch_gets_called'] = True

        def mock_update_changelog(unused_branch_name,
                                  unused_release_summary_lines,
                                  unused_current_release_version_number):
            check_function_calls['update_changelog_gets_called'] = True

        def mock_update_authors(unused_release_summary_lines):
            check_function_calls['update_authors_gets_called'] = True

        def mock_update_contributors(unused_release_summary_lines):
            check_function_calls['update_contributors_gets_called'] = True

        def mock_update_developer_names(unused_release_summary_lines):
            check_function_calls['update_developer_names_gets_called'] = True

        def mock_check_ordering_of_sections(unused_release_summary_lines):
            check_function_calls[
                'check_ordering_of_sections_gets_called'] = True

        def mock_create_branch(unused_repo_fork, unused_target_branch,
                               unused_github_username,
                               unused_current_release_version_number):
            check_function_calls['create_branch_gets_called'] = True

        def mock_input():
            return 'y'

        def mock_get_repo(unused_self, unused_repo_name):
            return self.mock_repo

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

        remove_updates_swap = self.swap(update_changelog_and_credits,
                                        'remove_updates_and_delete_branch',
                                        mock_remove_updates_and_delete_branch)
        update_changelog_swap = self.swap(update_changelog_and_credits,
                                          'update_changelog',
                                          mock_update_changelog)
        update_authors_swap = self.swap(update_changelog_and_credits,
                                        'update_authors', mock_update_authors)
        update_contributors_swap = self.swap(update_changelog_and_credits,
                                             'update_contributors',
                                             mock_update_contributors)
        update_developer_names_swap = self.swap(update_changelog_and_credits,
                                                'update_developer_names',
                                                mock_update_developer_names)
        check_order_swap = self.swap(update_changelog_and_credits,
                                     'check_ordering_of_sections',
                                     mock_check_ordering_of_sections)
        create_branch_swap = self.swap(update_changelog_and_credits,
                                       'create_branch', mock_create_branch)
        input_swap = self.swap(python_utils, 'INPUT', mock_input)
        get_repo_swap = self.swap(github.Github, 'get_repo', mock_get_repo)
        open_tab_swap = self.swap(common,
                                  'open_new_tab_in_browser_if_possible',
                                  mock_open_tab)

        with self.branch_name_swap, self.release_summary_swap, self.args_swap:
            with self.main_swap, self.getpass_swap, input_swap:
                with remove_updates_swap, update_authors_swap, open_tab_swap:
                    with update_changelog_swap, update_contributors_swap:
                        with update_developer_names_swap, check_order_swap:
                            with create_branch_swap, get_repo_swap:
                                update_changelog_and_credits.main()

        self.assertEqual(check_function_calls, expected_check_function_calls)