Exemple #1
0
  def testAcceptProposalTwice(self):
    # accept proposal as project
    project_one = proposal_logic.acceptProposal(self.proposal)

    # and again
    project_two = proposal_logic.acceptProposal(self.proposal)

    # the same entity should actually be returned
    self.assertEqual(project_one.key(), project_two.key())
Exemple #2
0
    def testAcceptProposalTwice(self):
        # accept proposal as project
        project_one = proposal_logic.acceptProposal(self.proposal)

        # and again
        project_two = proposal_logic.acceptProposal(self.proposal)

        # the same entity should actually be returned
        self.assertEqual(project_one.key(), project_two.key())
    def acceptProposalTxn():
      """Transaction that puts the new project, sets the proposal to accepted
      and mails the lucky student.
      """

      # add a task that performs conversion status per proposal
      # TODO(daniel): run in transaction when proposal and project are NDB
      # status_task.add(transactional=transactional)
      status_task.add(transactional=False)

      proposal = db.get(proposal_key)
      proposal_logic.acceptProposal(proposal)

      accepted_mail_txn()
      welcome_mail_txn()
Exemple #4
0
  def testAcceptTwoProposalsForStudent(self):
    # seed another proposal
    proposal_two = proposal_utils.seedProposal(
        self.student.key, self.program.key(), org_key=self.organization.key,
        mentor_key=self.mentor.key, accept_as_project=True,
        abstract='test abstract')

    # accept both proposals
    proposal_logic.acceptProposal(self.proposal)
    proposal_logic.acceptProposal(proposal_two)

    # student info should reflect that
    student = self.student.key.get()
    self.assertEqual(student.student_data.number_of_projects, 2)
    self.assertListEqual(
        student.student_data.project_for_orgs, [self.organization.key])
      def accept_proposal_txn():
        """Accept the proposal within a transaction."""
        proposal = db.get(proposal_key)

        if not proposal:
          logging.warning("Proposal '%s' doesn't exist", proposal_key)
        elif proposal.status == proposal_model.STATUS_ACCEPTED:
          logging.warning("Proposal '%s' already accepted", proposal_key)
        else:
          # check if the proposal has been assigned a mentor
          mentor_key = (proposal_model.GSoCProposal.mentor
              .get_value_for_datastore(proposal))
          if not mentor_key:
            logging.warning(
                'Proposal with key %s cannot be accepted because no mentor has'
                ' been assigned to it.', proposal_key)
          else:
            proposal_logic.acceptProposal(proposal)
Exemple #6
0
    def testAcceptTwoProposalsForStudent(self):
        # seed another proposal
        proposal_two = proposal_utils.seedProposal(
            self.student.key,
            self.program.key(),
            org_key=self.organization.key,
            mentor_key=self.mentor.key,
            accept_as_project=True,
            abstract='test abstract')

        # accept both proposals
        proposal_logic.acceptProposal(self.proposal)
        proposal_logic.acceptProposal(proposal_two)

        # student info should reflect that
        student = self.student.key.get()
        self.assertEqual(student.student_data.number_of_projects, 2)
        self.assertListEqual(student.student_data.project_for_orgs,
                             [self.organization.key])
Exemple #7
0
            def accept_proposal_txn():
                """Accept the proposal within a transaction."""
                proposal = db.get(proposal_key)

                if not proposal:
                    logging.warning("Proposal '%s' doesn't exist",
                                    proposal_key)
                elif proposal.status == proposal_model.STATUS_ACCEPTED:
                    logging.warning("Proposal '%s' already accepted",
                                    proposal_key)
                else:
                    # check if the proposal has been assigned a mentor
                    mentor_key = (proposal_model.GSoCProposal.mentor.
                                  get_value_for_datastore(proposal))
                    if not mentor_key:
                        logging.warning(
                            'Proposal with key %s cannot be accepted because no mentor has'
                            ' been assigned to it.', proposal_key)
                    else:
                        proposal_logic.acceptProposal(proposal)
Exemple #8
0
  def testAcceptProposal(self):
    # accept proposal as project
    project = proposal_logic.acceptProposal(self.proposal)

    # proposal should be accepted
    self.assertEqual(self.proposal.status, proposal_model.STATUS_ACCEPTED)

    # number of projects should be increased
    student = self.student.key.get()
    self.assertEqual(student.student_data.number_of_projects, 1)

    # project should be created correctly
    self.assertIsNotNone(project)
    self.assertEqual(self.proposal.abstract, project.abstract)
    self.assertEqual(
        self.organization.key.to_old_key(),
        project_model.GSoCProject.org.get_value_for_datastore(project))
    self.assertEqual(self.program.key(), project.program.key())
    self.assertEqual(self.student.key.to_old_key(), project.parent_key())
    self.assertListEqual([self.mentor.key.to_old_key()], project.mentors)
Exemple #9
0
    def testAcceptProposal(self):
        # accept proposal as project
        project = proposal_logic.acceptProposal(self.proposal)

        # proposal should be accepted
        self.assertEqual(self.proposal.status, proposal_model.STATUS_ACCEPTED)

        # number of projects should be increased
        student = self.student.key.get()
        self.assertEqual(student.student_data.number_of_projects, 1)

        # project should be created correctly
        self.assertIsNotNone(project)
        self.assertEqual(self.proposal.abstract, project.abstract)
        self.assertEqual(
            self.organization.key.to_old_key(),
            project_model.GSoCProject.org.get_value_for_datastore(project))
        self.assertEqual(self.program.key(), project.program.key())
        self.assertEqual(self.student.key.to_old_key(), project.parent_key())
        self.assertListEqual([self.mentor.key.to_old_key()], project.mentors)
Exemple #10
0
  def testAcceptProposalWithoutMentor(self):
    self.proposal.mentor = None

    with self.assertRaises(ValueError):
      proposal_logic.acceptProposal(self.proposal)
Exemple #11
0
    def testAcceptProposalWithoutMentor(self):
        self.proposal.mentor = None

        with self.assertRaises(ValueError):
            proposal_logic.acceptProposal(self.proposal)