Exemple #1
0
    def test_commit_queue_flag(self):
        bugzilla = Bugzilla()

        bugzilla.committers = CommitterList(reviewers=[Reviewer("WebKit Reviewer", "*****@*****.**")],
            committers=[Committer("WebKit Committer", "*****@*****.**")],
            contributors=[Contributor("WebKit Contributor", "*****@*****.**")])

        def assert_commit_queue_flag(mark_for_landing, mark_for_commit_queue, expected, username=None):
            bugzilla.username = username
            capture = OutputCapture()
            capture.capture_output()
            try:
                self.assertEqual(bugzilla._commit_queue_flag(mark_for_landing=mark_for_landing, mark_for_commit_queue=mark_for_commit_queue), expected)
            finally:
                capture.restore_output()

        assert_commit_queue_flag(mark_for_landing=False, mark_for_commit_queue=False, expected='X', username='******')
        assert_commit_queue_flag(mark_for_landing=False, mark_for_commit_queue=True, expected='?', username='******')
        assert_commit_queue_flag(mark_for_landing=False, mark_for_commit_queue=True, expected='?', username='******')
        assert_commit_queue_flag(mark_for_landing=True, mark_for_commit_queue=True, expected='?', username='******')

        assert_commit_queue_flag(mark_for_landing=False, mark_for_commit_queue=False, expected='X', username='******')
        assert_commit_queue_flag(mark_for_landing=False, mark_for_commit_queue=True, expected='?', username='******')
        assert_commit_queue_flag(mark_for_landing=True, mark_for_commit_queue=False, expected='?', username='******')
        assert_commit_queue_flag(mark_for_landing=True, mark_for_commit_queue=True, expected='?', username='******')

        assert_commit_queue_flag(mark_for_landing=False, mark_for_commit_queue=False, expected='X', username='******')
        assert_commit_queue_flag(mark_for_landing=False, mark_for_commit_queue=True, expected='?', username='******')
        assert_commit_queue_flag(mark_for_landing=True, mark_for_commit_queue=False, expected='+', username='******')
        assert_commit_queue_flag(mark_for_landing=True, mark_for_commit_queue=True, expected='+', username='******')

        assert_commit_queue_flag(mark_for_landing=False, mark_for_commit_queue=False, expected='X', username='******')
        assert_commit_queue_flag(mark_for_landing=False, mark_for_commit_queue=True, expected='?', username='******')
        assert_commit_queue_flag(mark_for_landing=True, mark_for_commit_queue=False, expected='+', username='******')
        assert_commit_queue_flag(mark_for_landing=True, mark_for_commit_queue=True, expected='+', username='******')
Exemple #2
0
    def test_commit_queue_flag(self):
        bugzilla = Bugzilla()

        bugzilla.committers = CommitterList(
            reviewers=[Reviewer("WebKit Reviewer", "*****@*****.**")],
            committers=[Committer("WebKit Committer", "*****@*****.**")],
            contributors=[
                Contributor("WebKit Contributor", "*****@*****.**")
            ])

        def assert_commit_queue_flag(commit_flag, expected, username=None):
            bugzilla.username = username
            with OutputCapture():
                self.assertEqual(bugzilla._commit_queue_flag(commit_flag),
                                 expected)

        assert_commit_queue_flag(commit_flag=CommitQueueFlag.mark_for_nothing,
                                 expected='X',
                                 username='******')
        assert_commit_queue_flag(
            commit_flag=CommitQueueFlag.mark_for_commit_queue,
            expected='?',
            username='******')
        assert_commit_queue_flag(commit_flag=CommitQueueFlag.mark_for_landing,
                                 expected='?',
                                 username='******')

        assert_commit_queue_flag(commit_flag=CommitQueueFlag.mark_for_nothing,
                                 expected='X',
                                 username='******')
        assert_commit_queue_flag(
            commit_flag=CommitQueueFlag.mark_for_commit_queue,
            expected='?',
            username='******')
        assert_commit_queue_flag(commit_flag=CommitQueueFlag.mark_for_landing,
                                 expected='?',
                                 username='******')

        assert_commit_queue_flag(commit_flag=CommitQueueFlag.mark_for_nothing,
                                 expected='X',
                                 username='******')
        assert_commit_queue_flag(
            commit_flag=CommitQueueFlag.mark_for_commit_queue,
            expected='?',
            username='******')
        assert_commit_queue_flag(commit_flag=CommitQueueFlag.mark_for_landing,
                                 expected='+',
                                 username='******')

        assert_commit_queue_flag(commit_flag=CommitQueueFlag.mark_for_nothing,
                                 expected='X',
                                 username='******')
        assert_commit_queue_flag(
            commit_flag=CommitQueueFlag.mark_for_commit_queue,
            expected='?',
            username='******')
        assert_commit_queue_flag(commit_flag=CommitQueueFlag.mark_for_landing,
                                 expected='+',
                                 username='******')
Exemple #3
0
    def test_committer_lookup(self):
        committer = Committer('Test One', '*****@*****.**', 'one')
        reviewer = Reviewer(
            'Test Two', ['*****@*****.**', '*****@*****.**', '*****@*****.**'])
        contributor = Contributor('Test Three', ['*****@*****.**'], 'three')
        contributor_with_two_nicknames = Contributor('Other Four',
                                                     ['*****@*****.**'],
                                                     ['four', 'otherfour'])
        committer_list = CommitterList(
            committers=[committer],
            reviewers=[reviewer],
            contributors=[contributor, contributor_with_two_nicknames])

        # Test valid committer, reviewer and contributor lookup
        self.assertEqual(committer_list.committer_by_email('*****@*****.**'),
                         committer)
        self.assertEqual(committer_list.reviewer_by_email('*****@*****.**'),
                         reviewer)
        self.assertEqual(committer_list.committer_by_email('*****@*****.**'),
                         reviewer)
        self.assertEqual(committer_list.committer_by_email('*****@*****.**'),
                         reviewer)
        self.assertEqual(committer_list.reviewer_by_email('*****@*****.**'),
                         reviewer)
        self.assertEqual(committer_list.contributor_by_email('*****@*****.**'),
                         contributor)

        # Test valid committer, reviewer and contributor lookup
        self.assertEqual(committer_list.committer_by_name("Test One"),
                         committer)
        self.assertEqual(committer_list.committer_by_name("Test Two"),
                         reviewer)
        self.assertEqual(committer_list.committer_by_name("Test Three"), None)
        self.assertEqual(committer_list.contributor_by_name("Test Three"),
                         contributor)

        # Test that the first email is assumed to be the Bugzilla email address (for now)
        self.assertEqual(
            committer_list.committer_by_email('*****@*****.**').bugzilla_email(),
            '*****@*****.**')

        # Test that a known committer is not returned during reviewer lookup
        self.assertEqual(committer_list.reviewer_by_email('*****@*****.**'),
                         None)
        self.assertEqual(committer_list.reviewer_by_email('*****@*****.**'),
                         None)
        # and likewise that a known contributor is not returned for committer lookup.
        self.assertEqual(committer_list.committer_by_email('*****@*****.**'),
                         None)

        # Test that unknown email address fail both committer and reviewer lookup
        self.assertEqual(committer_list.committer_by_email('*****@*****.**'),
                         None)
        self.assertEqual(committer_list.reviewer_by_email('*****@*****.**'), None)

        # Test that emails returns a list.
        self.assertEqual(committer.emails, ['*****@*****.**'])

        self.assertEqual(committer.irc_nicknames, ['one'])
        self.assertEqual(committer_list.contributor_by_irc_nickname('one'),
                         committer)
        self.assertEqual(committer_list.contributor_by_irc_nickname('three'),
                         contributor)
        self.assertEqual(committer_list.contributor_by_irc_nickname('four'),
                         contributor_with_two_nicknames)
        self.assertEqual(
            committer_list.contributor_by_irc_nickname('otherfour'),
            contributor_with_two_nicknames)

        # Test that the lists returned are are we expect them.
        self.assertEqual(
            committer_list.contributors(),
            [contributor, contributor_with_two_nicknames, committer, reviewer])
        self.assertEqual(committer_list.committers(), [committer, reviewer])
        self.assertEqual(committer_list.reviewers(), [reviewer])

        self.assertEqual(committer_list.contributors_by_search_string('test'),
                         [contributor, committer, reviewer])
        self.assertEqual(committer_list.contributors_by_search_string('rad'),
                         [reviewer])
        self.assertEqual(committer_list.contributors_by_search_string('Two'),
                         [reviewer])
 def test_contributor_encoding(self):
     committer_encoding = Contributor(u'\u017dan M\u00fcller',
                                      '*****@*****.**', 'zmuller')
     self.assertTrue(str(committer_encoding))
Exemple #5
0
    def test_committer_lookup(self):
        account = Account('Test Zero', ['*****@*****.**', '*****@*****.**'], 'zero')
        committer = Committer('Test One', '*****@*****.**', 'one')
        reviewer = Reviewer('Test Two', ['*****@*****.**', '*****@*****.**', '*****@*****.**'])
        contributor = Contributor('Test Three', ['*****@*****.**'], 'three')
        contributor_with_two_nicknames = Contributor('Other Four', ['*****@*****.**', '*****@*****.**'], ['four', 'otherfour'])
        contributor_with_same_email_username = Contributor('Yet Another Four', ['*****@*****.**'], ['yetanotherfour'])
        committer_list = CommitterList(watchers=[account], committers=[committer], reviewers=[reviewer],
            contributors=[contributor, contributor_with_two_nicknames, contributor_with_same_email_username])

        # Test valid committer, reviewer and contributor lookup
        self.assertEqual(committer_list.account_by_email('*****@*****.**'), account)
        self.assertEqual(committer_list.committer_by_email('*****@*****.**'), committer)
        self.assertEqual(committer_list.reviewer_by_email('*****@*****.**'), reviewer)
        self.assertEqual(committer_list.committer_by_email('*****@*****.**'), reviewer)
        self.assertEqual(committer_list.committer_by_email('*****@*****.**'), reviewer)
        self.assertEqual(committer_list.reviewer_by_email('*****@*****.**'), reviewer)
        self.assertEqual(committer_list.contributor_by_email('*****@*****.**'), contributor)

        # Test valid committer, reviewer and contributor lookup
        self.assertEqual(committer_list.committer_by_name("Test One"), committer)
        self.assertEqual(committer_list.committer_by_name("Test Two"), reviewer)
        self.assertIsNone(committer_list.committer_by_name("Test Three"))
        self.assertEqual(committer_list.contributor_by_name("Test Three"), contributor)
        self.assertEqual(committer_list.contributor_by_name("test one"), committer)
        self.assertEqual(committer_list.contributor_by_name("test two"), reviewer)
        self.assertEqual(committer_list.contributor_by_name("test three"), contributor)

        # Test that the first email is assumed to be the Bugzilla email address (for now)
        self.assertEqual(committer_list.committer_by_email('*****@*****.**').bugzilla_email(), '*****@*****.**')

        # Test lookup by login email address
        self.assertEqual(committer_list.account_by_login('*****@*****.**'), account)
        self.assertIsNone(committer_list.account_by_login('*****@*****.**'))
        self.assertEqual(committer_list.account_by_login('*****@*****.**'), committer)
        self.assertEqual(committer_list.account_by_login('*****@*****.**'), reviewer)
        self.assertIsNone(committer_list.account_by_login('*****@*****.**'))
        self.assertIsNone(committer_list.account_by_login('*****@*****.**'))

        # Test that a known committer is not returned during reviewer lookup
        self.assertIsNone(committer_list.reviewer_by_email('*****@*****.**'))
        self.assertIsNone(committer_list.reviewer_by_email('*****@*****.**'))
        # and likewise that a known contributor is not returned for committer lookup.
        self.assertIsNone(committer_list.committer_by_email('*****@*****.**'))

        # Test that unknown email address fail both committer and reviewer lookup
        self.assertIsNone(committer_list.committer_by_email('*****@*****.**'))
        self.assertIsNone(committer_list.reviewer_by_email('*****@*****.**'))

        # Test that emails returns a list.
        self.assertEqual(committer.emails, ['*****@*****.**'])

        self.assertEqual(committer.irc_nicknames, ['one'])
        self.assertEqual(committer_list.contributor_by_irc_nickname('one'), committer)
        self.assertEqual(committer_list.contributor_by_irc_nickname('three'), contributor)
        self.assertEqual(committer_list.contributor_by_irc_nickname('four'), contributor_with_two_nicknames)
        self.assertEqual(committer_list.contributor_by_irc_nickname('otherfour'), contributor_with_two_nicknames)

        # Test that the lists returned are are we expect them.
        self.assertEqual(committer_list.contributors(), [contributor, contributor_with_two_nicknames, contributor_with_same_email_username, committer, reviewer])
        self.assertEqual(committer_list.committers(), [committer, reviewer])
        self.assertEqual(committer_list.reviewers(), [reviewer])

        self.assertEqual(committer_list.contributors_by_search_string('test'), [contributor, committer, reviewer])
        self.assertEqual(committer_list.contributors_by_search_string('rad'), [reviewer])
        self.assertEqual(committer_list.contributors_by_search_string('Two'), [reviewer])
        self.assertEqual(committer_list.contributors_by_search_string('otherfour'), [contributor_with_two_nicknames])
        self.assertEqual(committer_list.contributors_by_search_string('*otherfour*'), [contributor_with_two_nicknames, contributor_with_same_email_username])

        self.assertEqual(committer_list.contributors_by_email_username("one"), [committer])
        self.assertEqual(committer_list.contributors_by_email_username("four"), [])
        self.assertEqual(committer_list.contributors_by_email_username("otherfour"), [contributor_with_two_nicknames, contributor_with_same_email_username])