Exemplo n.º 1
0
 def test_status_rejected_doesnt_override_vote(self):
     # Test that approve sets the status of the merge proposal.
     self.context.vote = CodeReviewVote.NEEDS_FIXING
     command = UpdateStatusEmailCommand('status', ['rejected'])
     command.execute(self.context)
     self.assertEqual(
         BranchMergeProposalStatus.REJECTED,
         self.merge_proposal.queue_status)
     self.assertEqual(CodeReviewVote.NEEDS_FIXING, self.context.vote)
 def test_status_rejected_doesnt_override_vote(self):
     # Test that approve sets the status of the merge proposal.
     self.context.vote = CodeReviewVote.NEEDS_FIXING
     command = UpdateStatusEmailCommand('status', ['rejected'])
     command.execute(self.context)
     self.assertEqual(
         BranchMergeProposalStatus.REJECTED,
         self.merge_proposal.queue_status)
     self.assertEqual(CodeReviewVote.NEEDS_FIXING, self.context.vote)
Exemplo n.º 3
0
 def test_status_rejected(self):
     # Test that rejected sets the status of the merge proposal.
     self.assertNotEqual(
         BranchMergeProposalStatus.REJECTED,
         self.merge_proposal.queue_status)
     command = UpdateStatusEmailCommand('status', ['rejected'])
     command.execute(self.context)
     self.assertEqual(
         BranchMergeProposalStatus.REJECTED,
         self.merge_proposal.queue_status)
     # The vote is also set if it wasn't before.
     self.assertEqual(CodeReviewVote.DISAPPROVE, self.context.vote)
     # Commit the transaction to check database permissions.
     transaction.commit()
Exemplo n.º 4
0
 def test_numberOfArguments(self):
     # The command needs one and only one arg.
     command = UpdateStatusEmailCommand('status', [])
     error = self.assertRaises(
         EmailProcessingError, command.execute, self.context)
     self.assertEqual(
         "The 'status' argument expects 1 argument(s). It got 0.\n",
         str(error))
     command = UpdateStatusEmailCommand('status', ['approve', 'spam'])
     error = self.assertRaises(
         EmailProcessingError, command.execute, self.context)
     self.assertEqual(
         "The 'status' argument expects 1 argument(s). It got 2.\n",
         str(error))
 def test_status_rejected(self):
     # Test that rejected sets the status of the merge proposal.
     self.assertNotEqual(
         BranchMergeProposalStatus.REJECTED,
         self.merge_proposal.queue_status)
     command = UpdateStatusEmailCommand('status', ['rejected'])
     command.execute(self.context)
     self.assertEqual(
         BranchMergeProposalStatus.REJECTED,
         self.merge_proposal.queue_status)
     # The vote is also set if it wasn't before.
     self.assertEqual(CodeReviewVote.DISAPPROVE, self.context.vote)
     # Commit the transaction to check database permissions.
     transaction.commit()
Exemplo n.º 6
0
 def test_registrant_not_a_reviewer(self):
     # If the registrant is not a reviewer, they cannot update the status.
     self.context.user = self.context.merge_proposal.registrant
     command = UpdateStatusEmailCommand('status', ['approve'])
     with person_logged_in(self.context.user):
         error = self.assertRaises(
             EmailProcessingError, command.execute, self.context)
     target = self.merge_proposal.target_branch.bzr_identity
     self.assertEqual(
         "You are not a reviewer for the branch %s.\n" % target,
         str(error))
Exemplo n.º 7
0
 def test_unknown_status(self):
     # Unknown status values will cause an email response to the user.
     command = UpdateStatusEmailCommand('status', ['bob'])
     error = self.assertRaises(
         EmailProcessingError, command.execute, self.context)
     self.assertEqual(
         "The 'status' command expects any of the following arguments:\n"
         "approved, rejected\n\n"
         "For example:\n\n"
         "    status approved\n",
         str(error))