Beispiel #1
0
    def testGradingRecordsOverviewGet(self):
        grading_survey_group = self.createGradingSurveyGroup()
        url = '/gsoc/grading_records/overview/%s/%d' % (
            self.program.key().name(), grading_survey_group.key().id())
        response = self.get(url)
        self.assertResponseOK(response)
        self.assertGradingRecordsOverviewTemplatesUsed(response)

        # list response without any projects
        response = self.getListResponse(url, 0)
        self.assertIsJsonResponse(response)
        data = response.context['data']['']
        self.assertEqual(0, len(data))

        # list response with projects
        student = profile_utils.seedNDBStudent(self.program)
        project = project_utils.seedProject(student,
                                            self.program.key(),
                                            org_key=self.org.key)

        other_student = profile_utils.seedNDBStudent(self.program)
        project_utils.seedProject(other_student,
                                  self.program.key(),
                                  org_key=self.org.key)

        grading_record.updateOrCreateRecordsFor(grading_survey_group,
                                                [project])

        response = self.getListResponse(url, 0)
        self.assertIsJsonResponse(response)
        data = response.context['data']['']
        self.assertEqual(1, len(data))
Beispiel #2
0
    def testDashboardAsStudent(self):
        user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(user)
        profile_utils.seedNDBStudent(self.program, user=user)

        response = self.get(self._getDashboardUrl())
        self.assertResponseOK(response)
Beispiel #3
0
  def testSubmitProposalWhenInactive(self):
    """Test the submission of student proposals during the student signup
    period is not active.
    """
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    self.timeline_helper.orgSignup()
    url = '/gsoc/proposal/submit/' + self.org.key.id()
    response = self.get(url)
    self.assertResponseForbidden(response)

    self.timeline_helper.offSeason()
    url = '/gsoc/proposal/submit/' + self.org.key.id()
    response = self.get(url)
    self.assertResponseForbidden(response)

    self.timeline_helper.kickoff()
    url = '/gsoc/proposal/submit/' + self.org.key.id()
    response = self.get(url)
    self.assertResponseForbidden(response)

    self.timeline_helper.orgsAnnounced()
    url = '/gsoc/proposal/submit/' + self.org.key.id()
    response = self.get(url)
    self.assertResponseForbidden(response)

    self.timeline_helper.studentsAnnounced()
    url = '/gsoc/proposal/submit/' + self.org.key.id()
    response = self.get(url)
    self.assertResponseForbidden(response)
Beispiel #4
0
    def testStudentCannotAccess(self):
        user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(user)
        profile_utils.seedNDBStudent(self.program, user=user)

        response = self.get(self.url)
        self.assertErrorTemplatesUsed(response)
Beispiel #5
0
  def testDashboardAsStudent(self):
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    response = self.get(self._getDashboardUrl())
    self.assertResponseOK(response)
Beispiel #6
0
  def testStudentCannotAccess(self):
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    response = self.get(self.url)
    self.assertErrorTemplatesUsed(response)
  def testGradingRecordsOverviewGet(self):
    grading_survey_group = self.createGradingSurveyGroup()
    url = '/gsoc/grading_records/overview/%s/%d' % (
        self.program.key().name(), grading_survey_group.key().id())
    response = self.get(url)
    self.assertResponseOK(response)
    self.assertGradingRecordsOverviewTemplatesUsed(response)

    # list response without any projects
    response = self.getListResponse(url, 0)
    self.assertIsJsonResponse(response)
    data = response.context['data']['']
    self.assertEqual(0, len(data))

    # list response with projects
    student = profile_utils.seedNDBStudent(self.program)
    project = project_utils.seedProject(
        student, self.program.key(), org_key=self.org.key)

    other_student = profile_utils.seedNDBStudent(self.program)
    project_utils.seedProject(
        other_student, self.program.key(), org_key=self.org.key)

    grading_record.updateOrCreateRecordsFor(grading_survey_group, [project])

    response = self.getListResponse(url, 0)
    self.assertIsJsonResponse(response)
    data = response.context['data']['']
    self.assertEqual(1, len(data))
  def testAcceptTwoProposals(self):
    """Tests that two proposals can be accepted in the same request."""
    user = profile_utils.seedNDBUser(host_for=[self.program])
    profile_utils.loginNDB(user)

    mentor = profile_utils.seedNDBProfile(
        self.program.key(), mentor_for=[self.org.key])

    student_one = profile_utils.seedNDBStudent(self.program)
    proposal_one = proposal_utils.seedProposal(
        student_one.key, self.program.key(), org_key=self.org.key,
        mentor_key=mentor.key)
    student_two = profile_utils.seedNDBStudent(self.program)
    proposal_two = proposal_utils.seedProposal(
        student_two.key, self.program.key(), org_key=self.org.key,
        mentor_key=mentor.key)

    list_data = [
        {accept_withdraw_projects._PROPOSAL_KEY: str(proposal_one.key())},
        {accept_withdraw_projects._PROPOSAL_KEY: str(proposal_two.key())}
        ]

    post_data = {
        'button_id': 'accept',
        'data': json.dumps(list_data),
        'idx': 0,
        }
    self.post(self.url, post_data)

    # check if both proposals are accepted correctly
    proposal1 = proposal_model.GSoCProposal.get(proposal_one.key())
    self.assertEqual(proposal1.status, proposal_model.STATUS_ACCEPTED)

    proposal2 = proposal_model.GSoCProposal.get(proposal_two.key())
    self.assertEqual(proposal2.status, proposal_model.STATUS_ACCEPTED)
    def setUp(self):
        super(ProposalDuplicatesTest, self).setUp()
        self.init()

        self.timeline_helper.studentSignup()

        # set the organization as accepted and allocate some slots
        self.org.status = org_model.Status.ACCEPTED
        self.org.slot_allocation = 10
        self.org.put()

        # the first student has a two duplicates and one non-accepted proposal
        self.student1 = profile_utils.seedNDBStudent(self.program)
        for _ in range(_FIRST_STUDENT_NUMBER_OF_DUPLICATES):
            proposal_utils.seedProposal(self.student1.key,
                                        self.program.key(),
                                        org_key=self.org.key,
                                        accept_as_project=True)
        proposal_utils.seedProposal(self.student1.key,
                                    self.program.key(),
                                    org_key=self.org.key,
                                    accept_as_project=False)

        # the other student has two proposals; one of them is to be accepted.
        self.student2 = profile_utils.seedNDBStudent(self.program)
        proposal_utils.seedProposal(self.student2.key,
                                    self.program.key(),
                                    org_key=self.org.key,
                                    accept_as_project=True)
        proposal_utils.seedProposal(self.student2.key,
                                    self.program.key(),
                                    org_key=self.org.key,
                                    accept_as_project=False)
Beispiel #10
0
  def testStudentAccessForbidden(self):
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    response = self.get(self._getUrl())
    self.assertErrorTemplatesUsed(response)
  def testAccessToTheList(self):
    """Tests only the host can access the list."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    response = self.get(self.url)
    self.assertResponseForbidden(response)

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(
        self.program.key(), user=user,
        mentor_for=[ndb.Key.from_old_key(self.org.key())])

    response = self.get(self.url)
    self.assertResponseForbidden(response)

    # check for an organization administrator
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(
        self.program.key(), user=user,
        admin_for=[ndb.Key.from_old_key(self.org.key())])

    response = self.get(self.url)
    self.assertResponseForbidden(response)

    user = profile_utils.seedNDBUser(host_for=[self.program])
    profile_utils.loginNDB(user)
    response = self.get(self.url)
    self.assertResponseOK(response)
  def setUp(self):
    super(ProposalDuplicatesTest, self).setUp()
    self.init()

    self.timeline_helper.studentSignup()

    # set the organization as accepted and allocate some slots
    self.org.status = org_model.Status.ACCEPTED
    self.org.slot_allocation = 10
    self.org.put()

    # the first student has a two duplicates and one non-accepted proposal
    self.student1 = profile_utils.seedNDBStudent(self.program)
    for _ in range(_FIRST_STUDENT_NUMBER_OF_DUPLICATES):
      proposal_utils.seedProposal(
          self.student1.key, self.program.key(), org_key=self.org.key,
          accept_as_project=True)
    proposal_utils.seedProposal(
        self.student1.key, self.program.key(), org_key=self.org.key,
        accept_as_project=False)

    # the other student has two proposals; one of them is to be accepted.
    self.student2 = profile_utils.seedNDBStudent(self.program)
    proposal_utils.seedProposal(
        self.student2.key, self.program.key(), org_key=self.org.key,
        accept_as_project=True)
    proposal_utils.seedProposal(
        self.student2.key, self.program.key(), org_key=self.org.key,
        accept_as_project=False)
Beispiel #13
0
    def testStudentAccessForbidden(self):
        user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(user)
        profile_utils.seedNDBStudent(self.program, user=user)

        response = self.get(self._getUrl())
        self.assertErrorTemplatesUsed(response)
Beispiel #14
0
    def testForStudentProfile(self):
        """Tests that False is returned if a student profile exists."""
        # seed a student profile
        profile_utils.seedNDBStudent(self.program, user=self.user)

        result = validate.hasNonStudentProfileForProgram(
            self.user.key, self.program.key())
        self.assertFalse(result)
Beispiel #15
0
  def testCodeInStudentAccessDenied(self):
    """Tests that Code-in student cannot access the page."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    response = self.get(self.take_url)
    self.assertResponseForbidden(response)
Beispiel #16
0
  def testForStudentProfile(self):
    """Tests that False is returned if a student profile exists."""
    # seed a student profile
    profile_utils.seedNDBStudent(self.program, user=self.user)

    result = validate.hasNonStudentProfileForProgram(
        self.user.key, self.program.key())
    self.assertFalse(result)
  def testStudentAccessDenied(self):
    """Tests that students cannot access the page."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    response = self.get(self._getUrl())
    self.assertResponseForbidden(response)
Beispiel #18
0
  def setUp(self):
    self.program = program_utils.seedGSoCProgram()
    # An organization which has all its slots allocated.
    self.foo_organization = org_utils.seedSOCOrganization(
        self.program.key(), slot_allocation=2)

    self.foo_proposals = []
    for _ in range(2):
      student = profile_utils.seedNDBStudent(self.program)
      self.foo_proposals.append(
          proposal_utils.seedProposal(student.key, self.program.key(),
              org_key=self.foo_organization.key,
              status=proposal_model.STATUS_ACCEPTED))

    # Create an organization which has slots to be allocated. We create both
    # rejected and accepted proposals for this organization entity.
    self.bar_organization = org_utils.seedSOCOrganization(
        self.program.key(), slot_allocation=5)
    # Create some already accepted proposals for bar_organization.
    self.bar_accepted_proposals = []
    for _ in range(2):
      student = profile_utils.seedNDBStudent(self.program)
      self.bar_accepted_proposals.append(
          proposal_utils.seedProposal(student.key, self.program.key(),
              org_key=self.bar_organization.key,
              status=proposal_model.STATUS_ACCEPTED))
    # proposals which are yet to be accepted.
    self.bar_to_be_accepted_proposals = []
    for _ in range(3):
      student = profile_utils.seedNDBStudent(self.program)
      self.bar_to_be_accepted_proposals.append(
          proposal_utils.seedProposal(student.key, self.program.key(),
              org_key=self.bar_organization.key, accept_as_project=True,
              status=proposal_model.STATUS_PENDING))

    # proposals which were rejected.
    self.bar_rejected_proposals = []
    for _ in range(3):
      student = profile_utils.seedNDBStudent(self.program)
      self.bar_rejected_proposals.append(
          proposal_utils.seedProposal(student.key, self.program.key(),
              org_key=self.bar_organization.key, accept_as_project=False,
              status=proposal_model.STATUS_PENDING))

    # Create an organization for which the accepted proposals are more than
    # the available slots.
    self.happy_organization = org_utils.seedSOCOrganization(
        self.program.key(), slot_allocation=1)

    self.happy_accepted_proposals = []
    self.happy_accepted_proposals.append(
        proposal_utils.seedProposal(student.key, self.program.key(),
            org_key=self.happy_organization.key, score=2,
            status=proposal_model.STATUS_PENDING, accept_as_project=True))
    self.happy_accepted_proposals.append(
        proposal_utils.seedProposal(student.key, self.program.key(),
            org_key=self.happy_organization.key, score=5,
            status=proposal_model.STATUS_PENDING, accept_as_project=True))
Beispiel #19
0
  def testStudentAccessForbidden(self):
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    url = '/gsoc/program/create/' + self.sponsor.key().name()

    response = self.get(url)
    self.assertErrorTemplatesUsed(response)
Beispiel #20
0
    def testStudentAccessForbidden(self):
        user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(user)
        profile_utils.seedNDBStudent(self.program, user=user)

        url = '/gsoc/program/create/' + self.sponsor.key().name()

        response = self.get(url)
        self.assertErrorTemplatesUsed(response)
  def testStudentAccessForbidded(self):
    """Tests that a student cannot access the page."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    response = self.get(self.url)
    self.assertResponseForbidden(response)
    self.assertErrorTemplatesUsed(response)
Beispiel #22
0
  def testStudentDeniedAccess(self):
    """Tests that students are denied access."""
    # seed a profile who is a student
    profile_utils.seedNDBStudent(self.program, user=self.user)

    access_checker = access.ProgramAdministratorAccessChecker()
    with self.assertRaises(exception.UserError) as context:
      access_checker.checkAccess(self.data, None)
    self.assertEqual(context.exception.message,
        access._MESSAGE_NOT_PROGRAM_ADMINISTRATOR)
Beispiel #23
0
  def testPostButtonUnpublishByStudent(self):
    """Tests the unpublish button by a mentor."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    url = _taskPageURL(self.task)
    response = self.buttonPost(url, 'button_unpublish')

    self.assertResponseForbidden(response)
Beispiel #24
0
    def testStudentDeniedAccess(self):
        """Tests that students are denied access."""
        # seed a profile who is a student
        profile_utils.seedNDBStudent(self.program, user=self.user)

        access_checker = access.ProgramAdministratorAccessChecker()
        with self.assertRaises(exception.UserError) as context:
            access_checker.checkAccess(self.data, None)
        self.assertEqual(context.exception.message,
                         access._MESSAGE_NOT_PROGRAM_ADMINISTRATOR)
Beispiel #25
0
    def testDashboardAsStudent(self):
        user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(user)
        profile_utils.seedNDBStudent(self.program, user=user)

        url = '/gsoc/dashboard/' + self.gsoc.key().name()
        response = self.get(url)
        self.assertResponseOK(response)
        self.assertDashboardComponentTemplatesUsed(response)
        response = self.getListResponse(url, 1)
        self.assertIsJsonResponse(response)
Beispiel #26
0
  def testRedirectWithStudentProfilePage(self):
    self.timeline_helper.studentSignup()

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    url = '/gci/profile/student/' + self.gci.key().name()
    response = self.get(url)
    redirect_url = '/gci/profile/' + self.gci.key().name()
    self.assertResponseRedirect(response, redirect_url)
Beispiel #27
0
    def testRedirectWithStudentProfilePage(self):
        self.timeline_helper.studentSignup()

        user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(user)
        profile_utils.seedNDBStudent(self.program, user=user)

        url = '/gci/profile/student/' + self.gci.key().name()
        response = self.get(url)
        redirect_url = '/gci/profile/' + self.gci.key().name()
        self.assertResponseRedirect(response, redirect_url)
Beispiel #28
0
  def testDashboardAsStudent(self):
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    url = '/gsoc/dashboard/' + self.gsoc.key().name()
    response = self.get(url)
    self.assertResponseOK(response)
    self.assertDashboardComponentTemplatesUsed(response)
    response = self.getListResponse(url, 1)
    self.assertIsJsonResponse(response)
  def testStudentFormUpload(self):
    """Tests the studentsInfoList component of the dashboard."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    response = self.get(self.url)
    self.assertStudentFormUploadTemplatesUsed(response)
    self.assertResponseOK(response)

    self.assertContains(
        response, 'To download the sample form or one of its translations')
    def testStudentFormUpload(self):
        """Tests the studentsInfoList component of the dashboard."""
        user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(user)
        profile_utils.seedNDBStudent(self.program, user=user)

        response = self.get(self.url)
        self.assertStudentFormUploadTemplatesUsed(response)
        self.assertResponseOK(response)

        self.assertContains(
            response, 'To download the sample form or one of its translations')
Beispiel #31
0
  def testSummerOfCodeStudentAccessDenied(self):
    """Tests that Summer Of Code student cannot access the page."""
    # seed Summer Of Code program
    soc_program = program_utils.seedGSoCProgram()

    # seed Summer Of Code student
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(soc_program, user=user)

    response = self.get(self.take_url)
    self.assertResponseForbidden(response)
  def testCreateEvaluationForStudentWithoutProject(self):
    link_id = LinkIDProvider(ProjectSurvey).getValue()
    suffix = "%s/%s" % (self.gsoc.key().name(), link_id)

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    # test review GET
    url = '/gsoc/eval/student/edit/' + suffix
    response = self.get(url)
    self.assertResponseForbidden(response)
Beispiel #33
0
    def testCreateTaskDuringProgramForStudent(self):
        """Tests the task creation view during the program for org admin."""
        self.timeline_helper.tasksPubliclyVisible()

        user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(user)
        profile_utils.seedNDBStudent(self.program, user=user)

        url = '/gci/task/create/' + self.org.key().name()
        response = self.get(url)

        # Student can't create tasks
        self.assertResponseForbidden(response)
Beispiel #34
0
  def testCreateTaskDuringProgramForStudent(self):
    """Tests the task creation view during the program for org admin."""
    self.timeline_helper.tasksPubliclyVisible()

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    url = '/gci/task/create/' + self.org.key().name()
    response = self.get(url)

    # Student can't create tasks
    self.assertResponseForbidden(response)
Beispiel #35
0
  def testPostButtonPublishByStudent(self):
    """Tests the publish button pressed by a student."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    self.task.status = 'Unpublished'
    self.task.put()

    url = _taskPageURL(self.task)
    response = self.buttonPost(url, 'button_publish')

    self.assertResponseForbidden(response)
Beispiel #36
0
  def testCreateTaskAfterClaimEndForStudent(self):
    """Tests the task creation view after the task claim deadline for student.
    """
    self.timeline_helper.taskClaimEnded()

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    url = '/gci/task/create/' + self.org.key().name()
    response = self.get(url)

    # Task creation is not open
    self.assertResponseForbidden(response)
Beispiel #37
0
    def testCreateTaskAfterClaimEndForStudent(self):
        """Tests the task creation view after the task claim deadline for student.
    """
        self.timeline_helper.taskClaimEnded()

        user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(user)
        profile_utils.seedNDBStudent(self.program, user=user)

        url = '/gci/task/create/' + self.org.key().name()
        response = self.get(url)

        # Task creation is not open
        self.assertResponseForbidden(response)
Beispiel #38
0
  def testCreateTaskBeforeOrgsAnnouncedForStudent(self):
    """Tests the task creation view before the program is public for org admin.
    """
    self.timeline_helper.orgSignup()

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    url = '/gci/task/create/' + self.org.key().name()
    response = self.get(url)

    # Task creation has not started yet
    self.assertResponseForbidden(response)
  def testShowEvalForStudentWithNoProject(self):
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    # test student evaluation show GET for a for a student who
    # does not have a project in the program
    url, evaluation, _ = self.getStudentEvalRecordProperties(show=True)
    response = self.get(url)
    self.assertResponseForbidden(response)

    self.ffPastEval(evaluation)
    response = self.get(url)
    self.assertResponseForbidden(response)
Beispiel #40
0
    def testCreateTaskBeforeOrgsAnnouncedForStudent(self):
        """Tests the task creation view before the program is public for org admin.
    """
        self.timeline_helper.orgSignup()

        user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(user)
        profile_utils.seedNDBStudent(self.program, user=user)

        url = '/gci/task/create/' + self.org.key().name()
        response = self.get(url)

        # Task creation has not started yet
        self.assertResponseForbidden(response)
Beispiel #41
0
    def testBulkTaskCreateDuringProgramForStudent(self):
        """Tests the bulk task create view during the program
    for students.
    """
        self.timeline_helper.tasksPubliclyVisible()

        user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(user)
        profile_utils.seedNDBStudent(self.program, user=user)

        url = '/gci/bulk/' + self.org.key().name()
        response = self.get(url)

        # Student can't bulk create tasks
        self.assertResponseForbidden(response)
Beispiel #42
0
  def testBulkTaskCreateDuringProgramForStudent(self):
    """Tests the bulk task create view during the program
    for students.
    """
    self.timeline_helper.tasksPubliclyVisible()

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    url = '/gci/bulk/' + self.org.key().name()
    response = self.get(url)

    # Student can't bulk create tasks
    self.assertResponseForbidden(response)
Beispiel #43
0
  def testPostButtonExtendDeadline(self):
    """Tests the extend deadline button."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(
        self.program.key(), user=user,
        mentor_for=[ndb.Key.from_old_key(self.org.key())])

    student = profile_utils.seedNDBStudent(self.program)

    # set it in the future so that the auto state transfer doesn't trigger
    deadline = datetime.datetime.utcnow() + datetime.timedelta(hours=24)

    self.task.status = 'Claimed'
    self.task.student = student.key.to_old_key()
    self.task.deadline = deadline
    self.task.put()

    url = _taskPageURL(self.task)
    response = self.buttonPost(
        url, 'button_extend_deadline', {'hours': 1})

    task = task_model.GCITask.get(self.task.key())
    self.assertResponseRedirect(response)

    delta = task.deadline - deadline
    self.assertTrue(delta.seconds == 3600)

    # check if a comment has been created
    comments = self.task.comments()
    self.assertEqual(len(comments), 1)
    self.assertMailSentToSubscribers(comments[0])

    self.assertBasicTaskView()
Beispiel #44
0
  def testPostButtonNeedsWork(self):
    """Tests the needs more work for task button."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(
        self.program.key(), user=user,
        mentor_for=[ndb.Key.from_old_key(self.org.key())])

    student = profile_utils.seedNDBStudent(self.program)

    self.task.status = 'NeedsReview'
    self.task.student = student.key.to_old_key()
    self.task.put()

    url = _taskPageURL(self.task)
    response = self.buttonPost(url, 'button_needs_work')

    # check if the task is properly closed
    task = task_model.GCITask.get(self.task.key())
    self.assertResponseRedirect(response)
    self.assertEqual(task.status, 'NeedsWork')
    self.assertEqual(
        task_model.GCITask.student.get_value_for_datastore(task),
        student.key.to_old_key())
    self.assertIsNone(task.deadline)

    # check if a comment has been created
    comments = self.task.comments()
    self.assertEqual(len(comments), 1)
    self.assertMailSentToSubscribers(comments[0])

    self.assertBasicTaskView()
Beispiel #45
0
  def testPostButtonClaim(self):
    """Tests the claim task button."""
    form = forms_to_submit_utils.FormsToSubmitHelper().createBlobStoreForm()
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedNDBStudent(
        self.program, user=user,
        student_data_properties={'enrollment_form': form, 'consent_form':form})

    url = _taskPageURL(self.task)
    response = self.buttonPost(url, 'button_claim')

    # check if the task is properly claimed
    task = task_model.GCITask.get(self.task.key())
    self.assertResponseRedirect(response)
    self.assertEqual(task.status, 'ClaimRequested')
    self.assertEqual(
        task_model.GCITask.student.get_value_for_datastore(task),
        student.key.to_old_key())

    # check if a comment has been created
    comments = self.task.comments()
    self.assertEqual(len(comments), 1)
    self.assertMailSentToSubscribers(comments[0])

    self.assertBasicTaskView()
  def testWithdrawProjects(self):
    user = profile_utils.seedNDBUser(host_for=[self.program])
    profile_utils.loginNDB(user)

    self.timeline_helper.studentsAnnounced()

    url = '/gsoc/withdraw_projects/' + self.program.key().name()
    response = self.get(url)
    self.assertResponseOK(response)
    self.assertWithdrawProjects(response)

    # list response without any projects
    response = self.getListResponse(url, 0)
    self.assertIsJsonResponse(response)
    data = response.context['data']['']
    self.assertEqual(0, len(data))

    # list response with projects
    student = profile_utils.seedNDBStudent(self.program)
    project_utils.seedProject(student, self.program.key(), org_key=self.org.key)

    response = self.getListResponse(url, 0)
    self.assertIsJsonResponse(response)
    data = response.context['data']['']
    self.assertEqual(1, len(data))
Beispiel #47
0
    def testDashboardAsStudentWithEval(self):
        user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(user)
        profile = profile_utils.seedNDBStudent(self.program, user=user)

        project_utils.seedProject(profile, self.program.key())

        url = '/gsoc/dashboard/' + self.gsoc.key().name()
        response = self.get(url)
        self.assertResponseOK(response)
        self.assertDashboardComponentTemplatesUsed(response)
        response = self.getListResponse(url, 3)
        self.assertResponseForbidden(response)

        response = self.get(url)
        self.assertResponseOK(response)
        self.assertDashboardComponentTemplatesUsed(response)
        self.evaluation = SurveyHelper(self.gsoc, self.dev_test)
        self.evaluation.createStudentEvaluation(
            override={'link_id': 'midterm'})
        response = self.getListResponse(url, 3)
        self.assertIsJsonResponse(response)
        data = json.loads(response.content)
        self.assertEqual(len(data['data']['']), 1)

        self.evaluation.createStudentEvaluation(override={'link_id': 'final'})
        response = self.getListResponse(url, 3)
        self.assertIsJsonResponse(response)
        data = json.loads(response.content)
        self.assertEqual(len(data['data']['']), 2)
Beispiel #48
0
  def testPostButtonUnclaim(self):
    """Tests the unclaim task button."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedNDBStudent(self.program, user=user)

    self.task.status = 'ClaimRequested'
    self.task.student = student.key.to_old_key()
    self.task.put()

    url = _taskPageURL(self.task)
    response = self.buttonPost(url, 'button_unclaim')

    # check if the task is properly opened
    task = task_model.GCITask.get(self.task.key())
    self.assertResponseRedirect(response)
    self.assertEqual(task.status, task_model.REOPENED)
    self.assertIsNone(task.student)
    self.assertIsNone(task.deadline)

    # check if a comment has been created
    comments = self.task.comments()
    self.assertEqual(len(comments), 1)
    self.assertMailSentToSubscribers(comments[0])

    self.assertBasicTaskView()
Beispiel #49
0
  def testPostSubmitWork(self):
    """Tests for submitting work."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedNDBStudent(self.program, user=user)

    self.task.status = 'Claimed'
    self.task.student = student.key.to_old_key()
    # set deadline to far future
    self.task.deadline = datetime.datetime.utcnow() + datetime.timedelta(days=1)
    self.task.put()

    no_work = self.task.workSubmissions()
    self.assertEqual(len(no_work), 0)

    work_url = 'http://www.example.com/'
    work_data = {
        'url_to_work': work_url
    }

    url = '%s?submit_work' % _taskPageURL(self.task)
    response = self.post(url, work_data)

    self.assertResponseRedirect(response)

    one_work = self.task.workSubmissions()
    self.assertEqual(len(one_work), 1)

    work = one_work[0]
    self.assertEqual(work_url, work.url_to_work)

    self.assertBasicTaskView()
Beispiel #50
0
  def testHasMentorProposalAssigned(self):
    """Unit test for proposal_logic.hasMentorProposalAssigned function."""
    # seed a new mentor
    mentor = profile_utils.seedNDBProfile(
        self.program.key(), mentor_for=[self.foo_organization.key])

    # mentor has no proposals
    has_proposal = proposal_logic.hasMentorProposalAssigned(mentor)
    self.assertFalse(has_proposal)

    # seed a new proposal and assign the mentor
    student = profile_utils.seedNDBStudent(self.program)
    proposal_utils.seedProposal(
        student.key, self.program.key(), org_key=self.foo_organization.key,
        mentor_key=mentor.key)

    # mentor has a proposal now
    has_proposal = proposal_logic.hasMentorProposalAssigned(mentor)
    self.assertTrue(has_proposal)

    # mentor has also proposal for foo organization
    has_proposal = proposal_logic.hasMentorProposalAssigned(
        mentor, org_key=self.foo_organization.key)
    self.assertTrue(has_proposal)

    # mentor does not have proposal for bar organization
    has_proposal = proposal_logic.hasMentorProposalAssigned(
        mentor, org_key=self.bar_organization.key)
    self.assertFalse(has_proposal)
  def testDoesNotGradingProjectSurveyReminderForWithdrawnProject(self):
    """Test withdrawn projects don't spawn reminder tasks for
    mentor evaluation.

    This covers all the evaluations created (midterm and final).
    """
    student = profile_utils.seedNDBStudent(self.program)
    project_utils.seedProject(
        student, self.program.key(), org_key=self.org.key, status='withdrawn')

    self.project.put()
    post_data = {
        'program_key': self.gsoc.key().id_or_name(),
        'survey_key': self.grading_survey.key().id_or_name(),
        'survey_type': 'grading'
        }

    response = self.post(self.SPAWN_URL, post_data)

    self.assertResponseOK(response)
    self.assertTasksInQueue(n=2)
    self.assertTasksInQueue(n=1, url=self.SPAWN_URL)
    # We have two projects in datastore and one is withdrawn, so we expect
    # to spawn the task for only one project.
    self.assertTasksInQueue(n=1, url=self.SEND_URL)
    def testGetRemainingTaskQuota(self):
        """Tests if the remaining task quota that can be published by a given
    organization is correctly returned.
    """
        gci_program_helper = GCIProgramHelper()
        org = gci_program_helper.createOrg()
        org.task_quota_limit = 5
        org.put()

        mentor = profile_utils.seedNDBProfile(
            self.program.key(), mentor_for=[ndb.Key.from_old_key(org.key())])
        student = profile_utils.seedNDBStudent(self.program)

        # valid tasks.
        for _ in xrange(3):
            task_utils.seedTask(self.program,
                                org, [mentor.key.to_old_key()],
                                student=student.key.to_old_key(),
                                status=task_model.CLOSED)
            # invalid tasks.
            task_utils.seedTask(self.program,
                                org, [mentor.key.to_old_key()],
                                student=student.key.to_old_key(),
                                status='Unpublished')
        expected_quota = org.task_quota_limit - 3
        actual_quota = org_logic.getRemainingTaskQuota(org)

        self.assertEqual(expected_quota, actual_quota)
Beispiel #53
0
    def testHomepageDuringSignup(self):
        """Tests the student homepage during the signup period."""
        self.timeline_helper.studentsAnnounced()
        url = '/gsoc/homepage/' + self.gsoc.key().name()
        response = self.get(url)
        self.assertResponseOK(response)
        self.assertHomepageTemplatesUsed(response)
        timeline_tmpl = response.context['timeline']
        apply_context = response.context['apply'].context()
        self.assertEqual(timeline_tmpl.current_timeline, 'coding_period')
        self.assertIn('profile_link', apply_context)

        # Show featured_project
        student = profile_utils.seedNDBStudent(self.program)
        project = project_utils.seedProject(student.key,
                                            self.program.key(),
                                            org_key=self.org.key,
                                            is_featured=True)

        response = self.get(url)
        self.assertResponseOK(response)
        self.assertHomepageTemplatesUsed(response)
        self.assertTemplateUsed(
            response, 'modules/gsoc/homepage/_featured_project.html')

        featured_project_tmpl = response.context['featured_project']
        self.assertEqual(featured_project_tmpl.featured_project.key(),
                         project.key())