def test_commit_info_creation(self): author = Committer("Author", "*****@*****.**") committer = Committer("Committer", "*****@*****.**") reviewer = Reviewer("Reviewer", "*****@*****.**") committer_list = CommitterList(committers=[author, committer], reviewers=[reviewer]) changelog_data = { "bug_id": 1234, "author_name": "Committer", "author_email": "*****@*****.**", "author": author, "reviewer_text": "Reviewer", "reviewer": reviewer, } commit = CommitInfo(123, "*****@*****.**", changelog_data, committer_list) self.assertEqual(commit.revision(), 123) self.assertEqual(commit.bug_id(), 1234) self.assertEqual(commit.author_name(), "Committer") self.assertEqual(commit.author_email(), "*****@*****.**") self.assertEqual(commit.author(), author) self.assertEqual(commit.reviewer_text(), "Reviewer") self.assertEqual(commit.reviewer(), reviewer) self.assertEqual(commit.committer(), committer) self.assertEqual(commit.committer_email(), "*****@*****.**") self.assertEqual(commit.responsible_parties(), set([author, committer, reviewer]))
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='******')
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='******')
def _create_patch(self, patch_contents): # FIXME: This code is brittle if the Attachment API changes. attachment = Attachment({"bug_id": 12345}, None) attachment.contents = lambda: patch_contents joe_cool = Committer(name="Joe Cool", email_or_emails=None) attachment.reviewer = lambda: joe_cool return attachment
def test_committer_lookup(self): committer = Committer('Test One', '*****@*****.**', 'one') reviewer = Reviewer( 'Test Two', ['*****@*****.**', '*****@*****.**', '*****@*****.**']) committer_list = CommitterList(committers=[committer], reviewers=[reviewer]) # Test valid committer and reviewer 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) # Test valid committer and reviewer 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) # 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) # 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_nickname, 'one') # Test that committers returns committers and reviewers and reviewers() just reviewers. self.assertEqual(committer_list.committers(), [committer, reviewer]) self.assertEqual(committer_list.reviewers(), [reviewer])
def author(self): # It's definitely possible to have commits with authors who # are not in our committers.py list. if not self._author_email: return None return Committer("Mock Committer", self._author_email)
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_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])