def testWithdrawProposalTwice(self): # try to withdraw the proposal twice proposal_logic.withdrawProposal(self.proposal, self.student) result = proposal_logic.withdrawProposal(self.proposal, self.student) # the result should also be true but number of proposals should not # be decreased twice self.assertTrue(result) self.assertEqual(proposal_model.STATUS_WITHDRAWN, self.proposal.status) self.assertEqual(self.student.student_data.number_of_proposals, 0)
def testWithdrawProposal(self): # try to withdraw the proposal result = proposal_logic.withdrawProposal(self.proposal, self.student) # the proposal should be withdrawn self.assertTrue(result) self.assertEqual(proposal_model.STATUS_WITHDRAWN, self.proposal.status) self.assertEqual(self.student.student_data.number_of_proposals, 0)
def withdrawProposalTxn(proposal_key, profile_key): """Withdraws the specified proposal in a transaction. Args: proposal_key: Proposal key. student_info_key: Student info key of the student who owns the proposal. """ proposal = db.get(proposal_key) profile = profile_key.get() return proposal_logic.withdrawProposal(proposal, profile)
def testForIneligibleProposal(self): # set the proposal status to accepted self.proposal.status = proposal_model.STATUS_ACCEPTED self.proposal.put() # try to withdraw the proposal result = proposal_logic.withdrawProposal(self.proposal, self.student) # the proposal should not be withdrawn self.assertFalse(result) self.assertEqual(proposal_model.STATUS_ACCEPTED, self.proposal.status) self.assertEqual(1, self.student.student_data.number_of_proposals)
def testWithdrawProposalForStudentWithFewProposals(self): # create a few other proposals for _ in range(3): proposal_utils.seedProposal(self.student.key, self.program.key()) # withdraw the main proposal result = proposal_logic.withdrawProposal(self.proposal, self.student) # the proposal should be withdrawn self.assertTrue(result) self.assertEqual(proposal_model.STATUS_WITHDRAWN, self.proposal.status) self.assertEqual(3, self.student.student_data.number_of_proposals)