Exemple #1
0
 def test_missing_release_summary_file(self):
     release_summary_swap = self.swap(release_constants,
                                      'RELEASE_SUMMARY_FILEPATH',
                                      'invalid.md')
     with self.branch_name_swap, release_summary_swap:
         with self.assertRaisesRegexp(
                 Exception,
             ('Release summary file invalid.md is missing. Please run '
              'the release_info.py script and re-run this script.')):
             wrap_up_release.main()
Exemple #2
0
    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.')):
            wrap_up_release.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.exists_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')):
                wrap_up_release.main()
    def test_function_calls(self):
        check_function_calls = {
            'remove_blocking_bugs_milestone_from_issues_gets_called': False,
            'remove_release_labels_gets_called': False,
        }
        expected_check_function_calls = {
            'remove_blocking_bugs_milestone_from_issues_gets_called': True,
            'remove_release_labels_gets_called': True,
        }

        def mock_remove_blocking_bugs_milestone_from_issues(unused_repo):
            check_function_calls[
                'remove_blocking_bugs_milestone_from_issues_gets_called'] = True

        def mock_remove_release_labels(unused_repo):
            check_function_calls['remove_release_labels_gets_called'] = True

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

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

        # pylint: disable=unused-argument
        def mock_getpass(prompt):
            return 'test-token'

        # pylint: enable=unused-argument

        remove_blocking_bugs_milestone_from_issues_swap = self.swap(
            wrap_up_release, 'remove_blocking_bugs_milestone_from_issues',
            mock_remove_blocking_bugs_milestone_from_issues)
        remove_release_labels_swap = self.swap(wrap_up_release,
                                               'remove_release_labels',
                                               mock_remove_release_labels)
        get_org_swap = self.swap(github.Github, 'get_organization',
                                 mock_get_organization)
        get_repo_swap = self.swap(github.Organization.Organization, 'get_repo',
                                  mock_get_repo)
        getpass_swap = self.swap(getpass, 'getpass', mock_getpass)

        with self.branch_name_swap, self.exists_swap, get_org_swap:
            with get_repo_swap, getpass_swap, remove_release_labels_swap:
                with remove_blocking_bugs_milestone_from_issues_swap:
                    wrap_up_release.main()

        self.assertEqual(check_function_calls, expected_check_function_calls)