def testTakeEvalForStudentProjectWithAnotherMentor(self):
    """Test that a student with a project in the same org but with a
    different mentor than the current mentor will be redirected.
    """
    url, evaluation, _ = self.getStudentEvalRecordProperties()

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

    student = profile_utils.seedSOCStudent(self.program)
    project_utils.seedProject(
        student, self.program.key(), mentor_key=mentor.key)

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

    project = project_model.GSoCProject.all().get()

    suffix = "%s/%s/%s/%s" % (
        self.gsoc.key().name(), evaluation.link_id,
        self.student.profile_id, project.key().id())

    base_url = '/gsoc/eval/student'

    self.ffPastEval(evaluation)
    response = self.get(url)
    show_url = '%s/show/%s' % (base_url, suffix)
    self.assertResponseRedirect(response, show_url)
  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)
示例#3
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)
  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))
示例#5
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))
示例#6
0
    def testListProjects(self):
        self.timeline_helper.studentsAnnounced()
        url = '/gsoc/projects/list/' + self.gsoc.key().name()
        response = self.get(url)
        self.assertResponseOK(response)
        self.assertProjectTemplatesUsed(response)

        response = self.getListResponse(url, 0)
        self.assertIsJsonResponse(response)
        data = response.context['data']['']
        self.assertEqual(0, len(data))

        student = profile_utils.seedSOCStudent(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))
        columns = response.context['data'][''][0]['columns']
        self.assertIn('key', columns)
        self.assertIn('title', columns)
        self.assertIn('mentors', columns)
        self.assertIn('student', columns)
        self.assertIn('org', columns)
示例#7
0
  def testListProjects(self):
    self.timeline_helper.studentsAnnounced()
    url = '/gsoc/projects/list/' + self.gsoc.key().name()
    response = self.get(url)
    self.assertResponseOK(response)
    self.assertProjectTemplatesUsed(response)

    response = self.getListResponse(url, 0)
    self.assertIsJsonResponse(response)
    data = response.context['data']['']
    self.assertEqual(0, len(data))

    student = profile_utils.seedSOCStudent(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))
    columns = response.context['data'][''][0]['columns']
    self.assertIn('key', columns)
    self.assertIn('title', columns)
    self.assertIn('mentors', columns)
    self.assertIn('student', columns)
    self.assertIn('org', columns)
  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))
示例#9
0
  def testSubmitAnotherForm(self):
    """Tests that another form may be resubmitted by a student."""
    self.timeline_helper.formSubmission()

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedSOCStudent(self.program, user=user)
    project_utils.seedProject(
        student, self.program.key(), org_key=self.org.key)

    # set initial tax form
    blob_key = self.createBlob('initial_tax_form.pdf')
    student.student_data.tax_form = blob_key
    student.put()

    # submit a new tax form
    with tempfile.NamedTemporaryFile() as test_file:
      # check for the enrollment form
      url = self._getTaxFormUrl()
      postdata = {'tax_form': test_file}
      response = self.post(url, postdata)
      self.assertResponseRedirect(
          response, self._getTaxFormUrl(validated=True))

      # check if the form has been submitted
      student = student.key.get()
      self.assertIsNotNone(student.student_data.tax_form)
      self.assertEqual(os.path.basename(test_file.name),
          student.student_data.tax_form)
示例#10
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)
示例#11
0
  def testForMentorWithProject(self):
    # seed a project for organization one and set a mentor
    student = profile_utils.seedSOCStudent(self.program)
    project_utils.seedProject(
        student, self.program.key(),
        org_key=self.organization.key, mentor_key=self.mentor.key)

    profile_logic.resignAsMentorForOrg(self.mentor, self.organization.key)

    # the profile should still be a mentor because of the project
    self.assertTrue(self.mentor.is_mentor)
    self.assertIn(self.organization.key, self.mentor.mentor_for)
示例#12
0
    def testDashboardAsStudentWithProject(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, 2)
        self.assertIsJsonResponse(response)
示例#13
0
  def testStudentAccessForbidden(self):
    # access should be forbidden because at this point students are not
    # permitted to upload their forms
    self.timeline_helper.studentsAnnounced()

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedSOCStudent(self.program, user=user)
    project_utils.seedProject(
        student, self.program.key(), org_key=self.org.key)

    self._assertAccessForbiddenForUrl(self._getEnrollmentFormUrl())
    self._assertAccessForbiddenForUrl(self._getTaxFormUrl())
  def testCreateEvaluationForStudent(self):
    link_id = LinkIDProvider(ProjectSurvey).getValue()
    suffix = "%s/%s" % (self.gsoc.key().name(), link_id)

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedNDBStudent(self.program, user=user)
    project_utils.seedProject(student, self.program.key(), org_key=self.org.key)

    # test review GET
    url = '/gsoc/eval/student/edit/' + suffix
    response = self.get(url)
    self.assertResponseForbidden(response)
示例#15
0
  def testDashboardAsStudentWithProject(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, 2)
    self.assertIsJsonResponse(response)
  def testCreateEvaluationForMentor(self):
    link_id = LinkIDProvider(ProjectSurvey).getValue()
    suffix = "%s/%s" % (self.gsoc.key().name(), link_id)

    student = profile_utils.seedNDBStudent(self.program)

    mentor = profile_utils.seedNDBProfile(
        self.program.key(), mentor_for=[self.org.key])
    project_utils.seedProject(
        student, self.program.key(), mentor_key=mentor.key)

    # test review GET
    url = '/gsoc/eval/student/edit/' + suffix
    response = self.get(url)
    self.assertResponseForbidden(response)
示例#17
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())
  def testTakeEvalForStudentProjectWithAnotherOrg(self):
    """Test that if a student with a project for an org attempts to take
    an evaluation for a different org, they will be redirected.
    """
    url, evaluation, _ = self.getStudentEvalRecordProperties()
    other_org = self.createOrg()

    project = project_model.GSoCProject.all().get()

    mentor = profile_utils.seedNDBProfile(
        self.program.key(), mentor_for=[other_org.key])
    other_student = profile_utils.seedSOCStudent(self.program)
    other_project = project_utils.seedProject(other_student,
        self.program.key(), org_key=other_org.key, mentor_key=mentor.key)

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

    suffix = "%s/%s/%s/%s" % (
        self.gsoc.key().name(), evaluation.link_id,
        self.student.profile_id, project.key().id())

    self.ffPastEval(evaluation)
    response = self.get(url)
    show_url = '/gsoc/eval/student/show/%s' % suffix
    self.assertResponseRedirect(response, show_url)
示例#19
0
  def setUp(self):
    self.program = program_utils.seedGSoCProgram()
    self.organization = org_utils.seedSOCOrganization(self.program.key())
    self.student = profile_utils.seedSOCStudent(self.program)

    # seed a project for above organization, program and student
    self.project = project_utils.seedProject(
        self.student, self.program.key(), org_key=self.organization.key)
示例#20
0
  def createProject(self):
    mentor = profile_utils.seedNDBProfile(
        self.program.key(), mentor_for=[self.org.key])
    student = profile_utils.seedSOCStudent(self.program)

    return project_utils.seedProject(
        student, self.program.key(), org_key=self.org.key,
        mentor_key=mentor.key)
  def testShowEvalForStudentProjectWithAnotherMentor(self):
    url, evaluation, _ = self.getStudentEvalRecordProperties(show=True)

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedNDBStudent(self.program, user=user)
    project_utils.seedProject(student, self.program.key(), org_key=self.org.key)

    # test student evaluation show GET for a for a student who
    # has another project whose mentor is different than the current
    # mentor but the project is in the same org
    response = self.get(url)
    self.assertResponseForbidden(response)

    self.ffPastEval(evaluation)
    response = self.get(url)
    self.assertResponseForbidden(response)
  def testShowEvalForAnotherStudentWithProject(self):
    url, evaluation, _ = self.getStudentEvalRecordProperties(show=True)

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedNDBStudent(self.program, user=user)
    project_utils.seedProject(student, self.program.key(), org_key=self.org.key)

    # test student evaluation show GET for a for a student who
    # has another project in the same org and whose mentor is
    # same as the student whose survey is being accessed
    response = self.get(url)
    self.assertResponseForbidden(response)

    self.ffPastEval(evaluation)
    response = self.get(url)
    self.assertResponseForbidden(response)
  def testShowEvalForStudentProjectWithAnotherOrg(self):
    url, evaluation, _ = self.getStudentEvalRecordProperties(show=True)
    other_org = self.createOrg()

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedNDBStudent(self.program, user=user)
    project_utils.seedProject(
        student, self.program.key(), org_key=other_org.key)

    # test student evaluation show GET for a for a student who
    # has another project in a different organization
    response = self.get(url)
    self.assertResponseForbidden(response)

    self.ffPastEval(evaluation)
    response = self.get(url)
    self.assertResponseForbidden(response)
示例#24
0
    def createProject(self):
        mentor = profile_utils.seedNDBProfile(self.program.key(),
                                              mentor_for=[self.org.key])
        student = profile_utils.seedSOCStudent(self.program)

        return project_utils.seedProject(student,
                                         self.program.key(),
                                         org_key=self.org.key,
                                         mentor_key=mentor.key)
示例#25
0
  def testDashboardAsMentorWithProject(self):
    self.timeline_helper.studentsAnnounced()

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

    student = profile_utils.seedSOCStudent(self.program)
    project_utils.seedProject(
        student, self.program.key(), org_key=self.org.key,
        mentor_key=profile.key)

    url = '/gsoc/dashboard/' + self.gsoc.key().name()
    response = self.get(url)
    self.assertResponseOK(response)
    self.assertDashboardComponentTemplatesUsed(response)
    response = self.getListResponse(url, 4)
    self.assertIsJsonResponse(response)
示例#26
0
  def _seedProjectData(self):
    # create a mentor
    self.mentor = profile_utils.seedNDBProfile(
        self.program.key(), mentor_for=[self.org.key])

    # create a student with a project
    self.student = profile_utils.seedSOCStudent(self.program)
    self.project = project_utils.seedProject(
        self.student, self.program.key(), org_key=self.org.key,
        mentor_key=self.mentor.key)
示例#27
0
  def testProjectList(self):
    """Tests that project list shows projects for the organization."""
    self.timeline_helper.studentsAnnounced()

    # seed a few projects for the organization
    for _ in range(NUMBER_OF_PROJECTS):
      student = profile_utils.seedSOCStudent(self.program)
      project_utils.seedProject(
          student, self.program.key(), org_key=self.org.key)

    # seed a project for another organization
    other_org = org_utils.seedSOCOrganization(self.program.key())
    student = profile_utils.seedSOCStudent(self.program)
    project_utils.seedProject(
        student, self.program.key(), org_key=other_org.key)

    # check that only orgs for the first organization are listed
    data = self.getListData(_getOrgHomeUrl(self.org), 0)
    self.assertEqual(NUMBER_OF_PROJECTS, len(data))
示例#28
0
    def _seedProjectData(self):
        # create a mentor
        self.mentor = profile_utils.seedNDBProfile(self.program.key(),
                                                   mentor_for=[self.org.key])

        # create a student with a project
        self.student = profile_utils.seedSOCStudent(self.program)
        self.project = project_utils.seedProject(self.student,
                                                 self.program.key(),
                                                 org_key=self.org.key,
                                                 mentor_key=self.mentor.key)
示例#29
0
  def testMentorWithProjectForOtherOrg(self):
    """Tests for a mentor who has a project for another organization."""
    # set our profile a mentor for organization two
    self.mentor.mentor_for.append(self.organization_two.key)
    self.mentor.put()

    # seed a project for organization two
    student = profile_utils.seedNDBStudent(self.program)
    project_utils.seedProject(
        student, self.program.key(), org_key=self.organization_two.key,
        mentor_key=self.mentor.key)

    # the mentor has a project
    has_projects = project_logic.hasMentorProjectAssigned(self.mentor)
    self.assertTrue(has_projects)

    # the mentor has only a project for organization two
    has_projects = project_logic.hasMentorProjectAssigned(
        self.mentor, org_key=self.organization_one.key)
    self.assertFalse(has_projects)
示例#30
0
  def testStudentAccessGranted(self):
    self.timeline_helper.formSubmission()

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedSOCStudent(self.program, user=user)
    project_utils.seedProject(
        student, self.program.key(), org_key=self.org.key)

    # check for enrollment form
    url = self._getEnrollmentFormUrl()
    response = self.get(url)
    self.assertResponseOK(response)
    self._assertStudentFormsTemplatesUsed(response)

    # check for tax form
    url = self._getTaxFormUrl()
    response = self.get(url)
    self.assertResponseOK(response)
    self._assertStudentFormsTemplatesUsed(response)
    def testDoesNotCreateGradingRecordForWithdrawnProject(self):
        # create another project and mark it withdrawn
        student = profile_utils.seedNDBStudent(self.program)

        project_utils.seedProject(
            student, self.program.key(), org_key=self.org.key, mentor_key=self.mentor.key, status="withdrawn"
        )

        post_data = {"group_key": self.survey_group.key().id_or_name()}

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

        self.assertResponseOK(response)
        self.assertTasksInQueue(n=1, url=self.UPDATE_RECORDS_URL)

        records = gr_model.GSoCGradingRecord.all().fetch(limit=1000)

        # Only one record is expected of the two projects since no record should
        # be created for the withdrawn project
        self.assertEqual(len(records), 1)
示例#32
0
  def testMentorWithProject(self):
    # seed a student
    student = profile_utils.seedSOCStudent(self.program)

    # seed a project for organization one
    project_utils.seedProject(
        student, self.program.key(),
        org_key=self.organization_one.key, mentor_key=self.mentor.key)

    # mentor is involved in organization one because of a project
    can_resign = profile_logic.canResignAsMentorForOrg(
        self.mentor, self.organization_one.key)
    self.assertFalse(can_resign)

    # add mentor role for organization two
    self.mentor.mentor_for.append(self.organization_two.key)

    # mentor is not involved in organization two
    can_resign = profile_logic.canResignAsMentorForOrg(
        self.mentor, self.organization_two.key)
    self.assertTrue(can_resign)
    def setUp(self):
        super(GradingSurveyGroupTest, self).setUp()
        self.init()

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

        self.student = profile_utils.seedNDBStudent(self.program)
        self.project = project_utils.seedProject(
            self.student, self.program.key(), org_key=self.org.key, mentor_key=self.mentor.key
        )

        self.createSurveys()
示例#34
0
    def testDashboardAsMentorWithProject(self):
        self.timeline_helper.studentsAnnounced()

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

        student = profile_utils.seedSOCStudent(self.program)
        project_utils.seedProject(student,
                                  self.program.key(),
                                  org_key=self.org.key,
                                  mentor_key=profile.key)

        url = '/gsoc/dashboard/' + self.gsoc.key().name()
        response = self.get(url)
        self.assertResponseOK(response)
        self.assertDashboardComponentTemplatesUsed(response)
        response = self.getListResponse(url, 4)
        self.assertIsJsonResponse(response)
  def setUp(self):
    super(SurveyRemindersTest, self).setUp()
    self.init()

    self.mentor = profile_utils.seedNDBProfile(
        self.program.key(), mentor_for=[self.org.key])
    self.student = profile_utils.seedNDBStudent(self.program)
    self.project = project_utils.seedProject(
        self.student, self.program.key(), org_key=self.org.key,
        mentor_key=self.mentor.key)

    self.createSurveys()
示例#36
0
    def testMentorWithProjectForOtherOrg(self):
        """Tests for a mentor who has a project for another organization."""
        # set our profile a mentor for organization two
        self.mentor.mentor_for.append(self.organization_two.key)
        self.mentor.put()

        # seed a project for organization two
        student = profile_utils.seedNDBStudent(self.program)
        project_utils.seedProject(student,
                                  self.program.key(),
                                  org_key=self.organization_two.key,
                                  mentor_key=self.mentor.key)

        # the mentor has a project
        has_projects = project_logic.hasMentorProjectAssigned(self.mentor)
        self.assertTrue(has_projects)

        # the mentor has only a project for organization two
        has_projects = project_logic.hasMentorProjectAssigned(
            self.mentor, org_key=self.organization_one.key)
        self.assertFalse(has_projects)
    def testDoesNotCreateGradingRecordForWithdrawnProject(self):
        # create another project and mark it withdrawn
        student = profile_utils.seedNDBStudent(self.program)

        project_utils.seedProject(student,
                                  self.program.key(),
                                  org_key=self.org.key,
                                  mentor_key=self.mentor.key,
                                  status='withdrawn')

        post_data = {'group_key': self.survey_group.key().id_or_name()}

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

        self.assertResponseOK(response)
        self.assertTasksInQueue(n=1, url=self.UPDATE_RECORDS_URL)

        records = gr_model.GSoCGradingRecord.all().fetch(limit=1000)

        # Only one record is expected of the two projects since no record should
        # be created for the withdrawn project
        self.assertEqual(len(records), 1)
示例#38
0
  def testMentorWithMoreProjects(self):
    """Tests for a mentor with more projects."""
    # seed a few extra projects and assign our mentor
    for _ in range(5):
      student = profile_utils.seedNDBStudent(self.program)
      self.project_one = project_utils.seedProject(
          student, self.program.key(), org_key=self.organization_one.key,
          mentor_key=self.mentor.key)

    # the mentor has projects for organization one
    has_projects = project_logic.hasMentorProjectAssigned(
        self.mentor, org_key=self.organization_one.key)
    self.assertTrue(has_projects)
示例#39
0
  def testTaxFormSubmissionByAdmin(self):
    """Tests that tax form is submitted properly by an admin."""
    self.timeline_helper.formSubmission()

    user = profile_utils.seedNDBUser(host_for=[self.program])
    profile_utils.loginNDB(user)

    student = profile_utils.seedSOCStudent(self.program)
    project_utils.seedProject(student, self.program.key(), org_key=self.org.key)

    # check that there is no tax form at this stage
    self.assertIsNone(student.student_data.tax_form)

    with tempfile.NamedTemporaryFile() as test_file:
      url = self._getAdminTaxForm(student)
      postdata = {'tax_form': test_file}
      response = self.post(url, postdata)
      self.assertResponseRedirect(
          response, self._getAdminTaxForm(student, validated=True))

      # check if the form has been submitted
      student = student.key.get()
      self.assertIsNotNone(student.student_data.tax_form)
示例#40
0
  def testStudentAccessForbidden(self):
    """Tests that students cannot access the page."""
    # try to access the page as a student who owns a project
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedNDBStudent(self.program, user=user)

    # create a project
    project = project_utils.seedProject(
        student, self.program.key(), org_key=self.org.key)

    response = self.get(self._getUrl(project))
    self.assertResponseForbidden(response)
    self.assertErrorTemplatesUsed(response)
示例#41
0
  def testEnrollmentFormSubmissionByStudent(self):
    """Tests that enrollment form is submitted properly by a student."""
    self.timeline_helper.formSubmission()

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedSOCStudent(self.program, user=user)
    project_utils.seedProject(
        student, self.program.key(), org_key=self.org.key)

    # check that there is no enrollment form at this stage
    self.assertIsNone(student.student_data.enrollment_form)

    with tempfile.NamedTemporaryFile() as test_file:
      # check for the enrollment form
      url = self._getEnrollmentFormUrl()
      postdata = {'enrollment_form': test_file}
      response = self.post(url, postdata)
      self.assertResponseRedirect(
          response, self._getEnrollmentFormUrl(validated=True))

      # check if the form has been submitted
      student = student.key.get()
      self.assertIsNotNone(student.student_data.enrollment_form)
示例#42
0
    def testStudentAccessForbidden(self):
        """Tests that students cannot access the page."""
        # try to access the page as a student who owns a project
        user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(user)
        student = profile_utils.seedNDBStudent(self.program, user=user)

        # create a project
        project = project_utils.seedProject(student,
                                            self.program.key(),
                                            org_key=self.org.key)

        response = self.get(self._getUrl(project))
        self.assertResponseForbidden(response)
        self.assertErrorTemplatesUsed(response)
示例#43
0
    def testMentorWithMoreProjects(self):
        """Tests for a mentor with more projects."""
        # seed a few extra projects and assign our mentor
        for _ in range(5):
            student = profile_utils.seedNDBStudent(self.program)
            self.project_one = project_utils.seedProject(
                student,
                self.program.key(),
                org_key=self.organization_one.key,
                mentor_key=self.mentor.key)

        # the mentor has projects for organization one
        has_projects = project_logic.hasMentorProjectAssigned(
            self.mentor, org_key=self.organization_one.key)
        self.assertTrue(has_projects)
  def testTakeEvalForAnotherStudentWithProject(self):
    url, evaluation, mentor = self.getStudentEvalRecordProperties()

    student = profile_utils.seedSOCStudent(self.program)
    project_utils.seedProject(
        student, self.program.key(), mentor_key=mentor.key)
    # test student evaluation show GET for a for a student who
    # has another project in the same org and whose mentor is
    # same as the student whose survey is being accessed
    response = self.get(url)
    self.assertResponseForbidden(response)

    project = project_model.GSoCProject.all().get()

    suffix = "%s/%s/%s/%s" % (
        self.gsoc.key().name(), evaluation.link_id,
        self.student.profile_id, project.key().id())

    base_url = '/gsoc/eval/student'

    self.ffPastEval(evaluation)
    response = self.get(url)
    show_url = '%s/show/%s' % (base_url, suffix)
    self.assertResponseRedirect(response, show_url)
  def testWithdrawProject(self):
    """Test if withdrawing a project updates all the datastore properties."""
    self.timeline_helper.studentsAnnounced()

    user = profile_utils.seedNDBUser(host_for=[self.program])
    profile_utils.loginNDB(user)

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

    old_number_of_projects = student.key.get().student_data.number_of_projects
    old_project_for_orgs = student.key.get().student_data.project_for_orgs[:]

    data_payload = [{
        'full_project_key': str(project.key()),
        }
    ]

    json_data = json.dumps(data_payload)

    postdata = {
        'data': json_data,
        'button_id': 'withdraw'
        }

    list_idx = 0
    url = '/gsoc/withdraw_projects/%s?fmt=json&marker=1&&idx=%s' % (
        self.program.key().name(), str(list_idx))

    response = self.post(url, postdata)
    self.assertResponseOK(response)

    student = student.key.get()
    project = db.get(project.key())

    proposal = project.proposal

    self.assertEqual(project.status, 'withdrawn')
    self.assertEqual(proposal.status, 'withdrawn')

    self.assertEqual(
        student.student_data.number_of_projects,
        old_number_of_projects - 1)

    old_project_for_orgs.remove(self.org.key)
    self.assertEqual(
        list(student.student_data.project_for_orgs), old_project_for_orgs)
示例#46
0
def _createProjectForStudent(program, org, dev_test, student=None):
    """Returns a newly created GSoCProject for the specified student.
  If a new student instance is not provided, a new profile is created.

  Args:
    program: GSoCProgram instance for which the project is to be created
    org: Organization entity.
    dev_test: whether it is dev test environment
    student: the specified GSoCProfile student instance to mentor the project

  Returns:
    the newly created GSoCProject instance
  """
    if not student:
        student = profile_utils.seedSOCStudent(program)

    return project_utils.seedProject(student, program.key(), org_key=org.key)
示例#47
0
    def testProjectExists(self):
        """Tests that project is returned correctly if exists."""
        sponsor = program_utils.seedSponsor()
        program = program_utils.seedProgram(sponsor_key=sponsor.key())

        profile = profile_utils.seedSOCStudent(program)
        project = project_utils.seedProject(profile, program.key())

        kwargs = {
            'sponsor': sponsor.link_id,
            'program': program.program_id,
            'user': profile.profile_id,
            'id': str(project.key().id())
        }
        data = request_data.RequestData(None, None, kwargs)
        url_project = data.url_project
        self.assertEqual(project.key(), url_project.key())
  def testPageLoads(self):
    """Tests that the page loads properly."""
    evaluation = self.evaluation_helper.createMentorEvaluation()

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

    student = profile_utils.seedSOCStudent(self.program)
    project = project_utils.seedProject(
        student, self.program.key(), org_key=self.org.key,
        mentor_key=mentor.key)

    # test mentor evaluation show GET for a mentor of the project
    response = self.get(
        _getMentorEvaluationTakePageUrl(self.program, evaluation, project))
    self.assertResponseOK(response)
    self.assertEvaluationTakeTemplateUsed(response)
示例#49
0
    def testMentorAccessForbidden(self):
        """Tests that mentors cannot access the page."""
        # try to access the page as a mentor who mentor a project
        user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(user)
        mentor = profile_utils.seedNDBProfile(self.program.key(),
                                              user=user,
                                              mentor_for=[self.org.key])

        # create a student with a project
        student = profile_utils.seedNDBStudent(self.program)
        project = project_utils.seedProject(student,
                                            self.program.key(),
                                            org_key=self.org.key,
                                            mentor_key=mentor.key)

        response = self.get(self._getUrl(project))
        self.assertResponseForbidden(response)
        self.assertErrorTemplatesUsed(response)
示例#50
0
    def setUp(self):
        # seed a new program
        self.program = program_utils.seedGSoCProgram()

        # seed a couple of organizations
        self.organization_one = org_utils.seedSOCOrganization(
            self.program.key())
        self.organization_two = org_utils.seedSOCOrganization(
            self.program.key())

        # seed a project for the organization one
        student = profile_utils.seedNDBStudent(self.program)
        self.project_one = project_utils.seedProject(
            student, self.program.key(), org_key=self.organization_one.key)
        self.project_one.mentors = []
        self.project_one.put()

        # seed a new mentor for organization one, but without projects
        self.mentor = profile_utils.seedNDBProfile(
            self.program.key(), mentor_for=[self.organization_one.key])