def testFeaturedProjectButton(self):
        self.timeline.studentsAnnounced()

        student = GSoCProfileHelper(self.gsoc, self.dev_test)
        student.createOtherUser('*****@*****.**')
        student.createStudent()

        self.data.createOrgAdmin(self.org)

        mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
        mentor.createOtherUser('*****@*****.**')
        mentor_entity = mentor.createMentor(self.org)

        project = self.createProject({
            'parent': self.data.profile,
            'mentor': mentor_entity
        })

        suffix = "%s/%s/%d" % (self.gsoc.key().name(),
                               self.data.user.key().name(), project.key().id())

        url = '/gsoc/project/featured/' + suffix
        postdata = {'value': 'unchecked'}
        response = self.post(url, postdata)

        self.assertResponseOK(response)

        project = GSoCProject.all().get()
        self.assertEqual(project.is_featured, True)
Пример #2
0
  def testSubmitProposal(self):
    mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor.createOtherUser('*****@*****.**')
    mentor.createMentor(self.org)
    mentor.notificationSettings(
        new_proposals=True, public_comments=True, private_comments=True)

    other_mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
    other_mentor.createOtherUser('*****@*****.**')
    other_mentor.createMentor(self.org)
    other_mentor.notificationSettings()

    self.data.createStudent()
    self.data.notificationSettings()
    self.timeline.studentSignup()
    url = '/gsoc/proposal/submit/' + self.org.key().name()
    response = self.get(url)
    self.assertProposalTemplatesUsed(response)

    # test proposal POST
    override = {
        'program': self.gsoc, 'score': 0, 'nr_scores': 0, 'mentor': None,
        'org': self.org, 'status': 'pending', 'accept_as_project': False,
        'is_editable_post_deadline': False, 'extra': None, 'has_mentor': False,
    }
    response, properties = self.modelPost(url, GSoCProposal, override)
    self.assertResponseRedirect(response)

    self.assertEmailSent(to=mentor.profile.email, n=1)
    self.assertEmailNotSent(to=other_mentor.profile.email)

    proposal = GSoCProposal.all().get()
    self.assertPropertiesEqual(properties, proposal)
Пример #3
0
    def testDashboardAsStudentWithEval(self):
        mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
        mentor.createOtherUser('*****@*****.**').createMentor(self.org)
        self.data.createStudentWithProject(self.org, mentor.profile)
        url = '/gsoc/dashboard/' + self.gsoc.key().name()
        response = self.get(url)
        self.assertDashboardComponentTemplatesUsed(response)
        response = self.getListResponse(url, 3)
        self.assertResponseForbidden(response)

        response = self.get(url)
        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 testWithdrawProjects(self):
        self.data.createHost()
        self.timeline.studentsAnnounced()

        url = '/gsoc/withdraw_projects/' + self.gsoc.key().name()
        response = self.get(url)
        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
        mentor_profile_helper = GSoCProfileHelper(self.gsoc, self.dev_test)
        mentor_profile_helper.createOtherUser('*****@*****.**')
        mentor = mentor_profile_helper.createMentor(self.org)
        self.data.createStudentWithProposal(self.org, mentor)
        self.data.createStudentWithProject(self.org, mentor)

        response = self.getListResponse(url, 0)
        self.assertIsJsonResponse(response)
        data = response.context['data']['']
        self.assertEqual(1, len(data))
Пример #5
0
 def createOrgAdmin(self, email, organization):
     """Creates an organization admin for the given organization.
 """
     profile_helper = GSoCProfileHelper(self.program, dev_test=False)
     profile_helper.createOtherUser(email)
     admin = profile_helper.createOrgAdmin(organization)
     return admin
Пример #6
0
  def testAcceptProposalButton(self):
    student = GSoCProfileHelper(self.gsoc, self.dev_test)
    student.createOtherUser('*****@*****.**')
    student.createStudent()

    proposal = self.createProposal({'scope': student.profile,
                                    'parent': student.profile})

    suffix = "%s/%s/%d" % (
        self.gsoc.key().name(),
        student.user.key().name(),
        proposal.key().id())

    self.data.createMentor(self.org)

    url = '/gsoc/proposal/accept/' + suffix
    postdata = {'value': 'unchecked'}
    response = self.post(url, postdata)

    # fail if mentor tries to accept the proposal
    self.assertResponseForbidden(response)

    proposal = GSoCProposal.all().get()
    self.assertFalse(proposal.accept_as_project)

    # accept the proposal as project when the org admin tries to accept
    # the proposal
    self.data.createOrgAdmin(self.org)
    response = self.post(url, postdata)
    self.assertResponseOK(response)

    proposal = GSoCProposal.all().get()
    self.assertTrue(proposal.accept_as_project)
Пример #7
0
  def testTakeEvalForStudent(self):
    eval = self.evaluation.createStudentEvaluation()

    mentor_profile = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor_profile.createOtherUser('*****@*****.**')
    mentor = mentor_profile.createMentor(self.org)

    self.data.createStudentWithProject(self.org, mentor)

    project = GSoCProject.all().get()

    base_url = '/gsoc/eval/student'
    suffix = "%s/%s/%s/%s" % (
        self.gsoc.key().name(), eval.link_id,
        project.parent().link_id, project.key().id())

    url = '%s/%s' % (base_url, suffix)

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

    self.assertContains(response, '%s' % (eval.title))
    self.assertContains(response, 'Project: %s' % (project.title))

    self.assertEqual(response.context['page_name'],
                     '%s' % (eval.title))
    form = response.context['forms'][0]

    self.assertFormFromSchema(form, eval.schema)

    postdata = {
        'frm-t1309871149671-item': 'one line text message',
        'frm-t1309871322655-item': ['Option 2', 'Option 3'],
        'frm-t1309871157535-item': """A quick brown fox jumped over a lazy dog.
        A quick brown fox jumped over a lazy dog. A quick brown fox jumped 
        over a lazy dog. A quick brown fox jumped over a lazy dog.""",
        }
    response = self.post(url, postdata)
    self.assertResponseOK(response)
    self.assertFormError(
        response, 'form', 'frm-t1310822212610-item',
        'This field is required.')

    postdata = {
        'frm-t1309871149671-item': 'one line text message',
        'frm-t1309871322655-item': ['Option 2', 'Option 3'],
        'frm-t1309871157535-item': """A quick brown fox jumped over a lazy dog.
        A quick brown fox jumped over a lazy dog. A quick brown fox jumped 
        over a lazy dog. A quick brown fox jumped over a lazy dog.""",
        'frm-t1310822212610-item': "Wa Wa",
        }
    response = self.post(url, postdata)
    self.assertResponseRedirect(response, '%s?validated' % (url,))

    self.ffPastEval(eval)
    response = self.get(url)
    show_url = '%s/show/%s' % (base_url, suffix)
    self.assertResponseRedirect(response, show_url)
Пример #8
0
  def testShowEvalForStudent(self):
    eval = self.evaluation.createStudentEvaluation()

    mentor_profile = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor_profile.createOtherUser('*****@*****.**')
    mentor = mentor_profile.createMentor(self.org)

    self.data.createStudentWithProject(self.org, mentor)

    project = GSoCProject.all().get()

    suffix = "%s/%s/%s/%s" % (
        self.gsoc.key().name(), eval.link_id,
        project.parent().link_id, project.key().id())

    url = '/gsoc/eval/student/show/%s' % (suffix,)

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

    self.ffPastEval(eval)
    response = self.get(url)
    self.assertEvaluationShowTemplateUsed(response)
Пример #9
0
  def testWithdrawProjects(self):
    self.data.createHost()
    self.timeline.studentsAnnounced()

    url = '/gsoc/withdraw_projects/' + self.gsoc.key().name()
    response = self.get(url)
    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
    mentor_profile_helper = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor_profile_helper.createOtherUser('*****@*****.**')
    mentor = mentor_profile_helper.createMentor(self.org)
    self.data.createStudentWithProposal(self.org, mentor)
    self.data.createStudentWithProject(self.org, mentor)

    response = self.getListResponse(url, 0)
    self.assertIsJsonResponse(response)
    data = response.context['data']['']
    self.assertEqual(1, len(data))
Пример #10
0
 def createOrgAdmin(self, email, organization):
   """Creates an organization admin for the given organization.
   """
   profile_helper = GSoCProfileHelper(self.program, dev_test=False)
   profile_helper.createOtherUser(email)
   admin = profile_helper.createOrgAdmin(organization)
   return admin
Пример #11
0
  def testTakeEvalForStudentProjectWithAnotherOrg(self):
    url, eval, _ = self.getStudentEvalRecordProperties()
    other_org = self.createOrg()

    mentor_profile = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor_profile.createOtherUser('*****@*****.**')
    mentor = mentor_profile.createMentor(other_org)

    self.data.createStudentWithProject(other_org, mentor)
    # 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)

    project = GSoCProject.all().get()

    suffix = "%s/%s/%s/%s" % (
        self.gsoc.key().name(), eval.link_id,
        project.parent().link_id, project.key().id())

    base_url = '/gsoc/eval/student'

    self.ffPastEval(eval)
    response = self.get(url)
    show_url = '%s/show/%s' % (base_url, suffix)
    self.assertResponseRedirect(response, show_url)
Пример #12
0
 def createMentor(self, email, organization):
   """Creates a mentor for the given organization.
   """
   profile_helper = GSoCProfileHelper(self.program, dev_test=False)
   profile_helper.createOtherUser(email)
   mentor = profile_helper.createMentor(organization)
   return mentor
Пример #13
0
    def testAcceptProposalButton(self):
        student = GSoCProfileHelper(self.gsoc, self.dev_test)
        student.createOtherUser('*****@*****.**')
        student.createStudent()

        proposal = self.createProposal({
            'scope': student.profile,
            'parent': student.profile
        })

        suffix = "%s/%s/%d" % (self.gsoc.key().name(),
                               student.user.key().name(), proposal.key().id())

        self.data.createMentor(self.org)

        url = '/gsoc/proposal/accept/' + suffix
        postdata = {'value': 'unchecked'}
        response = self.post(url, postdata)

        # fail if mentor tries to accept the proposal
        self.assertResponseForbidden(response)

        proposal = GSoCProposal.all().get()
        self.assertFalse(proposal.accept_as_project)

        # accept the proposal as project when the org admin tries to accept
        # the proposal
        self.data.createOrgAdmin(self.org)
        response = self.post(url, postdata)
        self.assertResponseOK(response)

        proposal = GSoCProposal.all().get()
        self.assertTrue(proposal.accept_as_project)
Пример #14
0
  def testFeaturedProjectButton(self):
    self.timeline.studentsAnnounced()

    student = GSoCProfileHelper(self.gsoc, self.dev_test)
    student.createOtherUser('*****@*****.**')
    student.createStudent()

    self.data.createOrgAdmin(self.org)

    mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor.createOtherUser('*****@*****.**')
    mentor_entity = mentor.createMentor(self.org)

    project = self.createProject({'parent': self.data.profile,
                                 'mentor': mentor_entity})

    suffix = "%s/%s/%d" % (
        self.gsoc.key().name(),
        self.data.user.key().name(),
        project.key().id())

    url = '/gsoc/project/featured/' + suffix
    postdata = {'value': 'unchecked'}
    response = self.post(url, postdata)

    self.assertResponseOK(response)

    project = GSoCProject.all().get()
    self.assertEqual(project.is_featured, True)
Пример #15
0
 def createMentor(self, email, organization):
     """Creates a mentor for the given organization.
 """
     profile_helper = GSoCProfileHelper(self.program, dev_test=False)
     profile_helper.createOtherUser(email)
     mentor = profile_helper.createMentor(organization)
     return mentor
Пример #16
0
  def testProposalsSubmissionLimit(self):
    self.gsoc.apps_tasks_limit = 5
    self.gsoc.put()

    mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor.createOtherUser('*****@*****.**')
    mentor.createMentor(self.org)
    mentor.notificationSettings(
        new_proposals=True, public_comments=True, private_comments=True)

    other_mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
    other_mentor.createOtherUser('*****@*****.**')
    other_mentor.createMentor(self.org)
    other_mentor.notificationSettings()

    self.data.createStudent()
    self.data.notificationSettings()
    self.timeline.studentSignup()

    override = {
        'program': self.gsoc, 'score': 0, 'nr_scores': 0, 'mentor': None,
        'org': self.org, 'status': 'pending', 'accept_as_project': False,
        'is_editable_post_deadline': False, 'extra': None, 'has_mentor': False,
    }

    url = '/gsoc/proposal/submit/' + self.org.key().name()

    # Try to submit proposals four times.
    for i in range(5):
      response, properties = self.modelPost(url, GSoCProposal, override)
      self.assertResponseRedirect(response)

    response, properties = self.modelPost(url, GSoCProposal, override)
    self.assertResponseForbidden(response)
 def createStudent(self):
     """Creates a Student with a project.
 """
     profile_helper = GSoCProfileHelper(self.gsoc, self.dev_test)
     profile_helper.createOtherUser('*****@*****.**')
     self.student = profile_helper.createStudentWithProject(
         self.org, self.mentor)
     self.project = GSoCProject.all().ancestor(self.student).get()
Пример #18
0
 def createStudent(self):
   """Creates a Student with a project.
   """
   profile_helper = GSoCProfileHelper(self.gsoc, self.dev_test)
   profile_helper.createOtherUser('*****@*****.**')
   self.student = profile_helper.createStudentWithProject(self.org,
                                                          self.mentor)
   self.project = GSoCProject.all().ancestor(self.student).get()
Пример #19
0
 def testDashboardAsStudentWithProject(self):
     mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
     mentor.createOtherUser('*****@*****.**').createMentor(self.org)
     self.data.createStudentWithProject(self.org, mentor.profile)
     url = '/gsoc/dashboard/' + self.gsoc.key().name()
     response = self.get(url)
     self.assertDashboardComponentTemplatesUsed(response)
     response = self.getListResponse(url, 2)
     self.assertIsJsonResponse(response)
Пример #20
0
 def createStudent(self, email, n_proposals):
   """Creates a student with proposals.
   """
   student = GSoCProfileHelper(self.gsoc, self.dev_test)
   student.createOtherUser(email)
   student.createStudentWithProposals(self.org, self.mentor.profile,
                                      n=n_proposals)
   student.notificationSettings()
   return student
Пример #21
0
 def createStudent(self, email, n_proposals):
   """Creates a student with proposals.
   """
   student = GSoCProfileHelper(self.gsoc, self.dev_test)
   student.createOtherUser(email)
   student.createStudentWithProposals(self.org, self.mentor.profile,
                                      n=n_proposals)
   student.notificationSettings()
   return student
Пример #22
0
 def testDashboardAsStudentWithProject(self):
   mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
   mentor.createOtherUser('*****@*****.**').createMentor(self.org)
   self.data.createStudentWithProject(self.org, mentor.profile)
   url = '/gsoc/dashboard/' + self.gsoc.key().name()
   response = self.get(url)
   self.assertDashboardComponentTemplatesUsed(response)
   response = self.getListResponse(url, 2)
   self.assertIsJsonResponse(response)
Пример #23
0
 def testDashboardAsMentorWithProject(self):
   self.timeline.studentsAnnounced()
   student = GSoCProfileHelper(self.gsoc, self.dev_test)
   student.createOtherUser('*****@*****.**').createStudent()
   self.data.createMentorWithProject(self.org, student.profile)
   url = '/gsoc/dashboard/' + self.gsoc.key().name()
   response = self.get(url)
   self.assertDashboardComponentTemplatesUsed(response)
   response = self.getListResponse(url, 4)
   self.assertIsJsonResponse(response)
Пример #24
0
  def createStudentProjects(self):
    """Creates two student projects.
    """
    from soc.modules.gsoc.models.student_project import StudentProject
    mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor.createOtherUser('*****@*****.**').createMentor(self.org)

    student = GSoCProfileHelper(self.gsoc, self.dev_test)
    student.createOtherUser('*****@*****.**')
    student.createStudentWithProjects(self.org, mentor.profile, 2)
Пример #25
0
    def createStudentProjects(self):
        """Creates two student projects.
    """
        from soc.modules.gsoc.models.student_project import StudentProject
        mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
        mentor.createOtherUser('*****@*****.**').createMentor(self.org)

        student = GSoCProfileHelper(self.gsoc, self.dev_test)
        student.createOtherUser('*****@*****.**')
        student.createStudentWithProjects(self.org, mentor.profile, 2)
Пример #26
0
 def testDashboardAsMentorWithProject(self):
     self.timeline.studentsAnnounced()
     student = GSoCProfileHelper(self.gsoc, self.dev_test)
     student.createOtherUser('*****@*****.**').createStudent()
     self.data.createMentorWithProject(self.org, student.profile)
     url = '/gsoc/dashboard/' + self.gsoc.key().name()
     response = self.get(url)
     self.assertDashboardComponentTemplatesUsed(response)
     response = self.getListResponse(url, 4)
     self.assertIsJsonResponse(response)
Пример #27
0
    def createRequest(self):
        """Creates and returns an accepted invitation for the current user.
    """
        # create other user to send invite to
        other_data = GSoCProfileHelper(self.gsoc, self.dev_test)
        other_data.createOtherUser('*****@*****.**')
        other_data.createProfile()
        request = other_data.createMentorRequest(self.org)

        return (other_data, request)
Пример #28
0
  def createRequest(self):
    """Creates and returns an accepted invitation for the current user.
    """
    # create other user to send invite to
    other_data = GSoCProfileHelper(self.gsoc, self.dev_test)
    other_data.createOtherUser('*****@*****.**')
    other_data.createProfile()
    request = other_data.createMentorRequest(self.org)

    return (other_data, request)
Пример #29
0
  def testDashboardAsHost(self):
    self.data.createHost()
    mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor.createOtherUser('*****@*****.**').createMentor(self.org)
    student = GSoCProfileHelper(self.gsoc, self.dev_test)
    student.createOtherUser('*****@*****.**')
    student.createStudentWithProject(self.org, mentor.profile)

    url = '/gsoc/dashboard/' + self.gsoc.key().name()
    response = self.get(url)
    self.assertDashboardTemplatesUsed(response)
Пример #30
0
    def testDashboardAsHost(self):
        self.data.createHost()
        mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
        mentor.createOtherUser('*****@*****.**').createMentor(self.org)
        student = GSoCProfileHelper(self.gsoc, self.dev_test)
        student.createOtherUser('*****@*****.**')
        student.createStudentWithProject(self.org, mentor.profile)

        url = '/gsoc/dashboard/' + self.gsoc.key().name()
        response = self.get(url)
        self.assertDashboardTemplatesUsed(response)
Пример #31
0
  def testCreateEvaluationForMentor(self):
    link_id = LinkIDProvider(ProjectSurvey).getValue()
    suffix = "%s/%s" % (self.gsoc.key().name(), link_id)

    student_profile = GSoCProfileHelper(self.gsoc, self.dev_test)
    student_profile.createOtherUser('*****@*****.**')
    student = student_profile.createStudent()

    self.data.createMentorWithProject(self.org, student)
    # test review GET
    url = '/gsoc/eval/student/edit/' + suffix
    response = self.get(url)
    self.assertResponseForbidden(response)
Пример #32
0
    def testOnlyAHostCanAccessTheAdminProfilePage(self):
        """Tests that only the host is allowed to access profile pages.
    """
        mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
        mentor.createOtherUser('*****@*****.**').createMentor(self.org)
        student = GSoCProfileHelper(self.gsoc, self.dev_test)
        student.createOtherUser('*****@*****.**')
        student.createStudentWithProject(self.org, mentor.profile)

        url = '/gsoc/profile/admin/' + student.profile.key().name()

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

        self.data.deleteProfile().createMentor(self.org)
        response = self.get(url)
        self.assertResponseForbidden(response)

        self.data.createOrgAdmin(self.org)
        response = self.get(url)
        self.assertResponseForbidden(response)

        self.data.deleteProfile().createProfile()
        self.data.createHost()

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

        context = response.context
        self.assertTrue('page_name' in context)
        self.assertTrue('program_name' in context)
        self.assertTrue('profile' in context)
        self.assertTrue('user' in context)
        self.assertTrue('links' in context)
        self.assertTrue('css_prefix' in context)
        self.assertTrue('submit_tax_link' in context)
        self.assertTrue('submit_enrollment_link' in context)

        self.assertEqual(1, len(context['links']))

        expected_page_name = '%s Profile - %s' % (self.data.program.short_name,
                                                  student.profile.name())
        actual_page_name = context['page_name']
        self.assertEqual(expected_page_name, actual_page_name)

        expected_program_name = self.data.program.name
        actual_program_name = context['program_name']
        self.assertEqual(expected_program_name, actual_program_name)
Пример #33
0
  def testOnlyAHostCanAccessTheAdminProfilePage(self):
    """Tests that only the host is allowed to access profile pages.
    """
    mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor.createOtherUser('*****@*****.**').createMentor(self.org)
    student = GSoCProfileHelper(self.gsoc, self.dev_test)
    student.createOtherUser('*****@*****.**')
    student.createStudentWithProject(self.org, mentor.profile)

    url = '/gsoc/profile/admin/' + student.profile.key().name()

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

    self.data.deleteProfile().createMentor(self.org)
    response = self.get(url)
    self.assertResponseForbidden(response)
    
    self.data.createOrgAdmin(self.org)
    response = self.get(url)
    self.assertResponseForbidden(response)

    self.data.deleteProfile().createProfile()
    self.data.createHost()

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

    context = response.context
    self.assertTrue('page_name' in context)
    self.assertTrue('program_name' in context)
    self.assertTrue('profile' in context)
    self.assertTrue('user' in context)
    self.assertTrue('links' in context)
    self.assertTrue('css_prefix' in context)
    self.assertTrue('submit_tax_link' in context)
    self.assertTrue('submit_enrollment_link' in context)

    self.assertEqual(1, len(context['links']))
    
    expected_page_name = '%s Profile - %s' % (self.data.program.short_name, 
                                              student.profile.name())
    actual_page_name = context['page_name']
    self.assertEqual(expected_page_name, actual_page_name)
    
    expected_program_name = self.data.program.name
    actual_program_name = context['program_name']
    self.assertEqual(expected_program_name, actual_program_name)
Пример #34
0
    def testRequestMentor(self):
        admin = GSoCProfileHelper(self.gsoc, self.dev_test)
        admin.createOtherUser('*****@*****.**')
        admin.createOrgAdmin(self.org)
        admin.notificationSettings(new_requests=True)

        other_admin = GSoCProfileHelper(self.gsoc, self.dev_test)
        other_admin.createOtherUser('*****@*****.**')
        other_admin.createOrgAdmin(self.org)
        other_admin.notificationSettings()

        # test GET
        self.data.createProfile()
        url = '/gsoc/request/' + self.org.key().name()
        response = self.get(url)
        self.assertRequestTemplatesUsed(response)

        # test POST
        override = {
            'status': 'pending',
            'role': 'mentor',
            'type': 'Request',
            'user': self.data.user,
            'org': self.org
        }
        response, properties = self.modelPost(url, GSoCRequest, override)

        request = GSoCRequest.all().get()
        self.assertPropertiesEqual(properties, request)

        self.assertEmailSent(to=admin.profile.email, n=1)
        self.assertEmailNotSent(to=other_admin.profile.email)

        # test withdrawing a request
        url = '/gsoc/request/%s/%s/%s' % (self.gsoc.key().name(),
                                          request.parent_key().name(),
                                          request.key().id())

        postdata = {'action': 'Withdraw'}
        response = self.post(url, postdata)
        self.assertResponseRedirect(response)
        request = GSoCRequest.all().get()
        self.assertEqual('withdrawn', request.status)

        # test that you can resubmit
        postdata = {'action': 'Resubmit'}
        response = self.post(url, postdata)
        self.assertResponseRedirect(response)
        request = GSoCRequest.all().get()
        self.assertEqual('pending', request.status)
Пример #35
0
  def testInviteOrgAdmin(self):
    # test GET
    self.data.createOrgAdmin(self.org)
    url = '/gsoc/invite/org_admin/' + self.org.key().name()
    response = self.client.get(url)
    self.assertInviteTemplatesUsed(response)

    # create other user to send invite to
    other_data = GSoCProfileHelper(self.gsoc, self.dev_test)
    other_user = other_data.createOtherUser('*****@*****.**')
    other_data.createProfile()

    # test POST
    override = {'link_id': other_user.link_id, 'status': 'pending',
                'role': 'org_admin', 'user': other_user, 'group': self.org,
                'type': 'Invitation'}
    response, properties = self.modelPost(url, Request, override)

    invitation = Request.all().get()
    properties.pop('link_id')
    self.assertPropertiesEqual(properties, invitation)

    invitation.delete()
    override['link_id'] = '*****@*****.**'
    response, properties = self.modelPost(url, Request, override)

    invitation = Request.all().get()
    properties.pop('link_id')
    self.assertPropertiesEqual(properties, invitation)
Пример #36
0
    def testUpdateProposal(self):
        """Test update proposals.
    """
        mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
        mentor.createOtherUser('*****@*****.**')
        mentor.createMentor(self.org)
        mentor.notificationSettings(proposal_updates=True)

        self.data.createStudentWithProposal(self.org, mentor.profile)
        self.data.notificationSettings()
        self.timeline.studentSignup()

        proposal = GSoCProposal.all().get()

        url = '/gsoc/proposal/update/%s/%s' % (self.gsoc.key().name(),
                                               proposal.key().id())
        response = self.get(url)
        self.assertProposalTemplatesUsed(response)

        override = {
            'program': self.gsoc,
            'score': 0,
            'nr_scores': 0,
            'has_mentor': True,
            'mentor': mentor.profile,
            'org': self.org,
            'status': 'pending',
            'action': 'Update',
            'is_publicly_visible': False,
            'extra': None,
            'accept_as_project': False,
            'is_editable_post_deadline': False
        }
        response, properties = self.modelPost(url, GSoCProposal, override)
        self.assertResponseRedirect(response)

        properties.pop('action')

        proposal = GSoCProposal.all().get()
        self.assertPropertiesEqual(properties, proposal)

        # after update last_modified_on should be updated which is not equal
        # to created_on
        self.assertNotEqual(proposal.created_on, proposal.last_modified_on)

        self.assertEmailSent(to=mentor.profile.email, n=1)
Пример #37
0
  def testShowEvalForStudentProjectWithAnotherOrg(self):
    url, eval, _ = self.getStudentEvalRecordProperties(show=True)
    other_org = self.createOrg()

    mentor_profile = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor_profile.createOtherUser('*****@*****.**')
    mentor = mentor_profile.createMentor(other_org)

    self.data.createStudentWithProject(other_org, mentor)
    # 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(eval)
    response = self.get(url)
    self.assertResponseForbidden(response)
Пример #38
0
  def testShowEvalForStudentProjectWithAnotherMentor(self):
    url, eval, _ = self.getStudentEvalRecordProperties(show=True)

    mentor_profile = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor_profile.createOtherUser('*****@*****.**')
    mentor = mentor_profile.createMentor(self.org)

    self.data.createStudentWithProject(self.org, mentor)
    # 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(eval)
    response = self.get(url)
    self.assertResponseForbidden(response)
Пример #39
0
  def testRequestMentor(self):
    admin = GSoCProfileHelper(self.gsoc, self.dev_test)
    admin.createOtherUser('*****@*****.**')
    admin.createOrgAdmin(self.org)
    admin.notificationSettings(new_requests=True)

    other_admin = GSoCProfileHelper(self.gsoc, self.dev_test)
    other_admin.createOtherUser('*****@*****.**')
    other_admin.createOrgAdmin(self.org)
    other_admin.notificationSettings()

    # test GET
    self.data.createProfile()
    url = '/gsoc/request/' + self.org.key().name()
    response = self.get(url)
    self.assertRequestTemplatesUsed(response)

    # test POST
    override = {'status': 'pending', 'role': 'mentor', 'type': 'Request',
                'user': self.data.user, 'org': self.org}
    response, properties = self.modelPost(url, GSoCRequest, override)

    request = GSoCRequest.all().get()
    self.assertPropertiesEqual(properties, request)

    self.assertEmailSent(to=admin.profile.email, n=1)
    self.assertEmailNotSent(to=other_admin.profile.email)

    # test withdrawing a request
    url = '/gsoc/request/%s/%s/%s' % (
        self.gsoc.key().name(),
        request.parent_key().name(),
        request.key().id())

    postdata = {'action': 'Withdraw'}
    response = self.post(url, postdata)
    self.assertResponseRedirect(response)
    request = GSoCRequest.all().get()
    self.assertEqual('withdrawn', request.status)

    # test that you can resubmit
    postdata = {'action': 'Resubmit'}
    response = self.post(url, postdata)
    self.assertResponseRedirect(response)
    request = GSoCRequest.all().get()
    self.assertEqual('pending', request.status)
Пример #40
0
  def testReviewProposalPublicView(self):
    student = GSoCProfileHelper(self.gsoc, self.dev_test)
    student.createOtherUser('*****@*****.**')
    student.createStudent()

    proposal = self.createProposal({'is_publicly_visible': True,
                                    'scope': student.profile,
                                    'parent': student.profile})

    suffix = "%s/%s/%d" % (
        self.gsoc.key().name(),
        student.user.key().name(),
        proposal.key().id())

    # test review GET
    url = '/gsoc/proposal/review/' + suffix
    response = self.get(url)
    self.assertGSoCTemplatesUsed(response)
    self.assertTemplateUsed(response, 'v2/modules/gsoc/proposal/review.html')
Пример #41
0
    def testWishToMentorButton(self):
        student = GSoCProfileHelper(self.gsoc, self.dev_test)
        student.createOtherUser('*****@*****.**')
        student.createStudent()

        self.data.createMentor(self.org)

        other_mentor = self.createMentorWithSettings(
            '*****@*****.**')

        proposal = self.createProposal({
            'scope': student.profile,
            'parent': student.profile
        })

        suffix = "%s/%s/%d" % (self.gsoc.key().name(),
                               student.user.key().name(), proposal.key().id())

        url = '/gsoc/proposal/wish_to_mentor/' + suffix
        postdata = {'value': 'unchecked'}
        response = self.post(url, postdata)

        proposal = GSoCProposal.all().get()
        self.assertTrue(self.data.profile.key() in proposal.possible_mentors)

        postdata = {'value': 'checked'}
        response = self.post(url, postdata)

        proposal = GSoCProposal.all().get()
        self.assertFalse(self.data.profile.key() in proposal.possible_mentors)

        other_mentor.profile.mentor_for = []
        other_mentor.profile.put()

        proposal.possible_mentors.append(other_mentor.profile.key())
        proposal.put()

        url = '/gsoc/proposal/review/' + suffix
        response = self.get(url)

        proposal = GSoCProposal.all().get()
        self.assertFalse(
            other_mentor.profile.key() in proposal.possible_mentors)
Пример #42
0
    def testProposalsSubmissionLimit(self):
        self.gsoc.apps_tasks_limit = 5
        self.gsoc.put()

        mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
        mentor.createOtherUser('*****@*****.**')
        mentor.createMentor(self.org)
        mentor.notificationSettings(new_proposals=True,
                                    public_comments=True,
                                    private_comments=True)

        other_mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
        other_mentor.createOtherUser('*****@*****.**')
        other_mentor.createMentor(self.org)
        other_mentor.notificationSettings()

        self.data.createStudent()
        self.data.notificationSettings()
        self.timeline.studentSignup()

        override = {
            'program': self.gsoc,
            'score': 0,
            'nr_scores': 0,
            'mentor': None,
            'org': self.org,
            'status': 'pending',
            'accept_as_project': False,
            'is_editable_post_deadline': False,
            'extra': None,
            'has_mentor': False,
        }

        url = '/gsoc/proposal/submit/' + self.org.key().name()

        # Try to submit proposals four times.
        for i in range(5):
            response, properties = self.modelPost(url, GSoCProposal, override)
            self.assertResponseRedirect(response)

        response, properties = self.modelPost(url, GSoCProposal, override)
        self.assertResponseForbidden(response)
Пример #43
0
    def testRequestMentor(self):
        admin = GSoCProfileHelper(self.gsoc, self.dev_test)
        admin.createOtherUser("*****@*****.**")
        admin.createOrgAdmin(self.org)
        admin.notificationSettings(new_requests=True)

        other_admin = GSoCProfileHelper(self.gsoc, self.dev_test)
        other_admin.createOtherUser("*****@*****.**")
        other_admin.createOrgAdmin(self.org)
        other_admin.notificationSettings()

        # test GET
        self.data.createProfile()
        url = "/gsoc/request/" + self.org.key().name()
        response = self.get(url)
        self.assertRequestTemplatesUsed(response)

        # test POST
        override = {"status": "pending", "role": "mentor", "type": "Request", "user": self.data.user, "org": self.org}
        response, properties = self.modelPost(url, GSoCRequest, override)

        request = GSoCRequest.all().get()
        self.assertPropertiesEqual(properties, request)

        self.assertEmailSent(to=admin.profile.email, n=1)
        self.assertEmailNotSent(to=other_admin.profile.email)

        # test withdrawing a request
        url = "/gsoc/request/%s/%s" % (self.gsoc.key().name(), request.key().id())

        postdata = {"action": "Withdraw"}
        response = self.post(url, postdata)
        self.assertResponseRedirect(response)
        request = GSoCRequest.all().get()
        self.assertEqual("withdrawn", request.status)

        # test that you can resubmit
        postdata = {"action": "Resubmit"}
        response = self.post(url, postdata)
        self.assertResponseRedirect(response)
        request = GSoCRequest.all().get()
        self.assertEqual("pending", request.status)
Пример #44
0
    def testProjectDetails(self):
        self.data.createStudent()
        self.timeline.studentsAnnounced()

        mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
        mentor.createOtherUser('*****@*****.**')
        mentor_entity = mentor.createMentor(self.org)

        project = self.createProject({
            'parent': self.data.profile,
            'mentor': mentor_entity
        })

        suffix = "%s/%s/%d" % (self.gsoc.key().name(),
                               self.data.user.key().name(), project.key().id())

        # test project details GET
        url = '/gsoc/project/' + suffix
        response = self.get(url)
        self.assertProjectDetailsTemplateUsed(response)
Пример #45
0
  def testProjectDetails(self):
    self.data.createStudent()
    self.timeline.studentsAnnounced()

    mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor.createOtherUser('*****@*****.**')
    mentor_entity = mentor.createMentor(self.org)

    project = self.createProject({'parent': self.data.profile,
                                 'mentor': mentor_entity})

    suffix = "%s/%s/%d" % (
        self.gsoc.key().name(),
        self.data.user.key().name(),
        project.key().id())

    # test project details GET
    url = '/gsoc/project/' + suffix
    response = self.get(url)
    self.assertProjectDetailsTemplateUsed(response)
Пример #46
0
    def testReviewProposalPublicView(self):
        student = GSoCProfileHelper(self.gsoc, self.dev_test)
        student.createOtherUser('*****@*****.**')
        student.createStudent()

        proposal = self.createProposal({
            'is_publicly_visible': True,
            'scope': student.profile,
            'parent': student.profile
        })

        suffix = "%s/%s/%d" % (self.gsoc.key().name(),
                               student.user.key().name(), proposal.key().id())

        # test review GET
        url = '/gsoc/proposal/review/' + suffix
        response = self.get(url)
        self.assertGSoCTemplatesUsed(response)
        self.assertTemplateUsed(response,
                                'v2/modules/gsoc/proposal/review.html')
Пример #47
0
    def testSubmitProposal(self):
        mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
        mentor.createOtherUser('*****@*****.**')
        mentor.createMentor(self.org)
        mentor.notificationSettings(new_proposals=True,
                                    public_comments=True,
                                    private_comments=True)

        other_mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
        other_mentor.createOtherUser('*****@*****.**')
        other_mentor.createMentor(self.org)
        other_mentor.notificationSettings()

        self.data.createStudent()
        self.data.notificationSettings()
        self.timeline.studentSignup()
        url = '/gsoc/proposal/submit/' + self.org.key().name()
        response = self.get(url)
        self.assertProposalTemplatesUsed(response)

        # test proposal POST
        override = {
            'program': self.gsoc,
            'score': 0,
            'nr_scores': 0,
            'mentor': None,
            'org': self.org,
            'status': 'pending',
            'accept_as_project': False,
            'is_editable_post_deadline': False,
            'extra': None,
            'has_mentor': False,
        }
        response, properties = self.modelPost(url, GSoCProposal, override)
        self.assertResponseRedirect(response)

        self.assertEmailSent(to=mentor.profile.email, n=1)
        self.assertEmailNotSent(to=other_mentor.profile.email)

        proposal = GSoCProposal.all().get()
        self.assertPropertiesEqual(properties, proposal)
Пример #48
0
  def testWishToMentorButton(self):
    student = GSoCProfileHelper(self.gsoc, self.dev_test)
    student.createOtherUser('*****@*****.**')
    student.createStudent()

    self.data.createMentor(self.org)

    other_mentor = self.createMentorWithSettings('*****@*****.**')

    proposal = self.createProposal({'scope': student.profile,
                                    'parent': student.profile})

    suffix = "%s/%s/%d" % (
    self.gsoc.key().name(),
    student.user.key().name(),
    proposal.key().id())

    url = '/gsoc/proposal/wish_to_mentor/' + suffix
    postdata = {'value': 'unchecked'}
    response = self.post(url, postdata)

    proposal = GSoCProposal.all().get()
    self.assertTrue(self.data.profile.key() in proposal.possible_mentors)

    postdata = {'value': 'checked'}
    response = self.post(url, postdata)

    proposal = GSoCProposal.all().get()
    self.assertFalse(self.data.profile.key() in proposal.possible_mentors)

    other_mentor.profile.mentor_for = []
    other_mentor.profile.put()

    proposal.possible_mentors.append(other_mentor.profile.key())
    proposal.put()

    url = '/gsoc/proposal/review/' + suffix
    response = self.get(url)

    proposal = GSoCProposal.all().get()
    self.assertFalse(other_mentor.profile.key() in proposal.possible_mentors)
Пример #49
0
    def createStudent(self):
        """Creates two new students the first one has a duplicate the second one has
    none.
    """
        profile_helper = GSoCProfileHelper(self.gsoc, self.dev_test)
        profile_helper.createOtherUser('*****@*****.**')
        self.student1 = profile_helper.createStudentWithProposals(
            self.org, self.mentor, 3)

        proposals = GSoCProposal.all().ancestor(self.student1).fetch(2)
        for p in proposals:
            p.accept_as_project = True
            p.put()

        profile_helper = GSoCProfileHelper(self.gsoc, self.dev_test)
        profile_helper.createOtherUser('*****@*****.**')
        self.student2 = profile_helper.createStudentWithProposals(
            self.org, self.mentor, 1)
        proposal = GSoCProposal.all().ancestor(self.student2).get()
        proposal.accept_as_project = True
        proposal.put()
Пример #50
0
  def createStudent(self):
    """Creates two new students the first one has a duplicate the second one has
    none.
    """
    profile_helper = GSoCProfileHelper(self.gsoc, self.dev_test)
    profile_helper.createOtherUser('*****@*****.**')
    self.student1 = profile_helper.createStudentWithProposals(
        self.org, self.mentor, 3)

    proposals = GSoCProposal.all().ancestor(self.student1).fetch(2)
    for p in proposals:
      p.accept_as_project = True
      p.put()

    profile_helper = GSoCProfileHelper(self.gsoc, self.dev_test)
    profile_helper.createOtherUser('*****@*****.**')
    self.student2 = profile_helper.createStudentWithProposals(
        self.org, self.mentor, 1)
    proposal = GSoCProposal.all().ancestor(self.student2).get()
    proposal.accept_as_project = True
    proposal.put()
Пример #51
0
  def testUpdateProposal(self):
    """Test update proposals.
    """
    mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor.createOtherUser('*****@*****.**')
    mentor.createMentor(self.org)
    mentor.notificationSettings(proposal_updates=True)

    self.data.createStudentWithProposal(self.org, mentor.profile)
    self.data.notificationSettings()
    self.timeline.studentSignup()

    proposal = GSoCProposal.all().get()

    url = '/gsoc/proposal/update/%s/%s' % (
        self.gsoc.key().name(), proposal.key().id())
    response = self.get(url)
    self.assertProposalTemplatesUsed(response)

    override = {
        'program': self.gsoc, 'score': 0, 'nr_scores': 0, 'has_mentor': True,
        'mentor': mentor.profile, 'org': self.org, 'status': 'pending',
        'action': 'Update', 'is_publicly_visible': False, 'extra': None,
        'accept_as_project': False, 'is_editable_post_deadline': False
    }
    response, properties = self.modelPost(url, GSoCProposal, override)
    self.assertResponseRedirect(response)

    properties.pop('action')

    proposal = GSoCProposal.all().get()
    self.assertPropertiesEqual(properties, proposal)

    # after update last_modified_on should be updated which is not equal
    # to created_on
    self.assertNotEqual(proposal.created_on, proposal.last_modified_on)

    self.assertEmailSent(to=mentor.profile.email, n=1)
Пример #52
0
    def createEvaluation(self, survey, host=None, override={}):
        if not host:
            host_profile = GSoCProfileHelper(self.program, self.dev_test)
            host_profile.createOtherUser('*****@*****.**')
            host = host_profile.createHost()

        # TODO (Madhu): Remove scope and author once the survey data conversion
        # is complete
        properties = {
            'program': self.program,
            'created_by': host,
            'prefix': 'gsoc_program',
            'schema': self.evalSchemaString(),
            'survey_content': None,
            'author': host,
            'modified_by': host,
            'scope': self.program,
            'key_name': SurveyKeyNameProvider(),
            'survey_start': timeline_utils.past(),
            'survey_end': timeline_utils.future(),
        }
        properties.update(override)
        return self.seed(survey, properties)
Пример #53
0
  def testAssignMentor(self):
    student = GSoCProfileHelper(self.gsoc, self.dev_test)
    student.createOtherUser('*****@*****.**')
    student.createStudent()

    proposal = self.createProposal({'scope': student.profile,
                                    'parent': student.profile})

    suffix = "%s/%s/%d" % (
        self.gsoc.key().name(),
        student.user.key().name(),
        proposal.key().id())

    self.data.createMentor(self.org)

    url = '/gsoc/proposal/assign_mentor/' + suffix
    postdata = {'assign_mentor': self.data.profile.key()}
    response = self.post(url, postdata)

    self.assertResponseForbidden(response)

    proposal = GSoCProposal.all().get()
    self.assertEqual(proposal.mentor, None)