def test_delete_pending_by_registrant(self):
     # A pending review can be deleted by the person requesting the review.
     reviewer = self.factory.makePerson()
     bmp = make_merge_proposal_without_reviewers(self.factory)
     login_person(bmp.registrant)
     review = bmp.nominateReviewer(reviewer=reviewer,
                                   registrant=bmp.registrant)
     review.delete()
     self.assertEqual([], list(bmp.votes))
 def test_delete_pending_by_registrant(self):
     # A pending review can be deleted by the person requesting the review.
     reviewer = self.factory.makePerson()
     bmp = make_merge_proposal_without_reviewers(self.factory)
     login_person(bmp.registrant)
     review = bmp.nominateReviewer(
         reviewer=reviewer, registrant=bmp.registrant)
     review.delete()
     self.assertEqual([], list(bmp.votes))
 def test_delete_not_pending(self):
     # A non-pending review reference cannot be deleted.
     reviewer = self.factory.makePerson()
     bmp = make_merge_proposal_without_reviewers(self.factory)
     login_person(reviewer)
     bmp.createComment(
         reviewer, 'Message subject', 'Message content',
         vote=CodeReviewVote.APPROVE)
     [review] = list(bmp.votes)
     self.assertRaises(ReviewNotPending, review.delete)
 def test_delete_not_pending(self):
     # A non-pending review reference cannot be deleted.
     reviewer = self.factory.makePerson()
     bmp = make_merge_proposal_without_reviewers(self.factory)
     login_person(reviewer)
     bmp.createComment(reviewer,
                       'Message subject',
                       'Message content',
                       vote=CodeReviewVote.APPROVE)
     [review] = list(bmp.votes)
     self.assertRaises(ReviewNotPending, review.delete)
 def test_delete_pending_by_target_branch_owner(self):
     # A pending review can be deleted by anyone with edit permissions on
     # the target branch.
     reviewer = self.factory.makePerson()
     bmp = make_merge_proposal_without_reviewers(self.factory)
     login_person(bmp.registrant)
     review = bmp.nominateReviewer(reviewer=reviewer,
                                   registrant=bmp.registrant)
     login_person(bmp.target_branch.owner)
     review.delete()
     self.assertEqual([], list(bmp.votes))
 def test_delete_pending_by_target_branch_owner(self):
     # A pending review can be deleted by anyone with edit permissions on
     # the target branch.
     reviewer = self.factory.makePerson()
     bmp = make_merge_proposal_without_reviewers(self.factory)
     login_person(bmp.registrant)
     review = bmp.nominateReviewer(
         reviewer=reviewer, registrant=bmp.registrant)
     login_person(bmp.target_branch.owner)
     review.delete()
     self.assertEqual([], list(bmp.votes))
Exemplo n.º 7
0
 def setUp(self):
     super(TestAddReviewerEmailCommand, self).setUp(
         user='******')
     self._old_policy = setSecurityPolicy(LaunchpadSecurityPolicy)
     self.merge_proposal = (
         make_merge_proposal_without_reviewers(self.factory))
     # Default the user to be the target branch owner, so they are
     # authorised to update the status.
     self.context = CodeReviewEmailCommandExecutionContext(
         self.merge_proposal, self.merge_proposal.target_branch.owner)
     self.reviewer = self.factory.makePerson()
     switch_dbuser(config.processmail.dbuser)
 def setUp(self):
     super(TestAddReviewerEmailCommand, self).setUp(
         user='******')
     self._old_policy = setSecurityPolicy(LaunchpadSecurityPolicy)
     self.merge_proposal = (
         make_merge_proposal_without_reviewers(self.factory))
     # Default the user to be the target branch owner, so they are
     # authorised to update the status.
     self.context = CodeReviewEmailCommandExecutionContext(
         self.merge_proposal, self.merge_proposal.target_branch.owner)
     self.reviewer = self.factory.makePerson()
     switch_dbuser(config.processmail.dbuser)
 def test_create_vote(self):
     """CodeReviewVotes can be created"""
     merge_proposal = make_merge_proposal_without_reviewers(self.factory)
     reviewer = self.factory.makePerson()
     login_person(merge_proposal.registrant)
     vote = merge_proposal.nominateReviewer(reviewer,
                                            merge_proposal.registrant)
     self.assertEqual(reviewer, vote.reviewer)
     self.assertEqual(merge_proposal.registrant, vote.registrant)
     self.assertEqual(merge_proposal, vote.branch_merge_proposal)
     self.assertEqual([vote], list(merge_proposal.votes))
     self.assertSqlAttributeEqualsDate(vote, 'date_created', UTC_NOW)
     self.assertProvides(vote, ICodeReviewVoteReference)
Exemplo n.º 10
0
 def test_reviewer_with_diff(self):
     """Requesting a review with a diff works."""
     bmp = make_merge_proposal_without_reviewers(self.factory)
     self.factory.makePreviewDiff(merge_proposal=bmp)
     # To record the diff in the librarian.
     transaction.commit()
     eric = self.factory.makePerson(name="eric", email="*****@*****.**")
     mail = self.factory.makeSignedMessage(body=' reviewer eric')
     email_addr = bmp.address
     switch_dbuser(config.processmail.dbuser)
     self.code_handler.process(mail, email_addr, None)
     [vote] = bmp.votes
     self.assertEqual(eric, vote.reviewer)
Exemplo n.º 11
0
 def test_reviewer_with_diff(self):
     """Requesting a review with a diff works."""
     bmp = make_merge_proposal_without_reviewers(self.factory)
     preview_diff = self.factory.makePreviewDiff(merge_proposal=bmp)
     # To record the diff in the librarian.
     transaction.commit()
     eric = self.factory.makePerson(name="eric", email="*****@*****.**")
     mail = self.factory.makeSignedMessage(body=' reviewer eric')
     email_addr = bmp.address
     switch_dbuser(config.processmail.dbuser)
     self.code_handler.process(mail, email_addr, None)
     [vote] = bmp.votes
     self.assertEqual(eric, vote.reviewer)
 def test_create_vote(self):
     """CodeReviewVotes can be created"""
     merge_proposal = make_merge_proposal_without_reviewers(self.factory)
     reviewer = self.factory.makePerson()
     login_person(merge_proposal.registrant)
     vote = merge_proposal.nominateReviewer(
         reviewer, merge_proposal.registrant)
     self.assertEqual(reviewer, vote.reviewer)
     self.assertEqual(merge_proposal.registrant, vote.registrant)
     self.assertEqual(merge_proposal, vote.branch_merge_proposal)
     self.assertEqual([vote], list(merge_proposal.votes))
     self.assertSqlAttributeEqualsDate(
         vote, 'date_created', UTC_NOW)
     self.assertProvides(vote, ICodeReviewVoteReference)
 def makeMergeProposalWithReview(self, completed=False):
     """Return a new merge proposal with a review."""
     bmp = make_merge_proposal_without_reviewers(self.factory)
     reviewer = self.factory.makePerson()
     if completed:
         login_person(reviewer)
         bmp.createComment(
             reviewer, 'Message subject', 'Message content',
             vote=CodeReviewVote.APPROVE)
         [review] = list(bmp.votes)
     else:
         login_person(bmp.registrant)
         review = bmp.nominateReviewer(
             reviewer=reviewer, registrant=bmp.registrant)
     return bmp, review
 def makeMergeProposalWithReview(self, completed=False):
     """Return a new merge proposal with a review."""
     bmp = make_merge_proposal_without_reviewers(self.factory)
     reviewer = self.factory.makePerson()
     if completed:
         login_person(reviewer)
         bmp.createComment(reviewer,
                           'Message subject',
                           'Message content',
                           vote=CodeReviewVote.APPROVE)
         [review] = list(bmp.votes)
     else:
         login_person(bmp.registrant)
         review = bmp.nominateReviewer(reviewer=reviewer,
                                       registrant=bmp.registrant)
     return bmp, review