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)
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')
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)
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)
def testAUserNotLoggedInIsRedirectedToLoginPage(self): """Tests that a user who is not logged in and trying to access its profile is redirected to a login page. """ profile_helper = GSoCProfileHelper(self.gsoc, self.dev_test) profile_helper.createOtherUser('*****@*****.**') profile_helper.createProfile() import os current_logged_in_account = os.environ.get('USER_EMAIL', None) try: os.environ['USER_EMAIL'] = '' url = '/gsoc/profile/admin/' + profile_helper.profile.key().name() response = self.get(url) self.assertResponseRedirect(response) expected_redirect_url = 'https://www.google.com/accounts/Login?'+\ 'continue=http%3A//Foo%3A8080'+url actual_redirect_url = response.get('location', None) self.assertEqual(expected_redirect_url, actual_redirect_url) finally: if current_logged_in_account is None: del os.environ['USER_EMAIL'] else: os.environ['USER_EMAIL'] = current_logged_in_account
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)
def testProposalModificationButton(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/modification/' + suffix postdata = {'value': 'unchecked'} response = self.post(url, postdata) self.assertResponseOK(response) proposal = GSoCProposal.all().get() self.assertTrue(proposal.is_editable_post_deadline)
def testIgnoreProposalButton(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/ignore/' + suffix postdata = {'value': 'unchecked'} response = self.post(url, postdata) self.assertResponseForbidden(response) proposal = GSoCProposal.all().get() self.assertNotEqual(proposal.status, 'ignored')
def createMentorWithSettings(self, email, notification_settings={}): mentor = GSoCProfileHelper(self.gsoc, self.dev_test) mentor.createOtherUser(email) mentor.createMentor(self.org) mentor.notificationSettings(**notification_settings) return mentor
def testInviteOrgAdmin(self): # test GET self.data.createOrgAdmin(self.org) url = '/gsoc/invite/org_admin/' + self.org.key().name() response = self.get(url) self.assertInviteTemplatesUsed(response) # create other user to send invite to other_data = GSoCProfileHelper(self.gsoc, self.dev_test) other_data.createOtherUser('*****@*****.**') other_data.createProfile() other_data.notificationSettings(new_invites=True) other_user = other_data.user # test POST override = { 'link_id': other_user.link_id, 'status': 'pending', 'role': 'org_admin', 'user': other_user, 'org': self.org, 'type': 'Invitation', 'parent': other_user, } response, properties = self.modelPost(url, GSoCRequest, override) self.assertEmailSent(to=other_data.profile.email, n=1) invitation = GSoCRequest.all().get() properties.pop('link_id') self.assertPropertiesEqual(properties, invitation) other_data2 = GSoCProfileHelper(self.gsoc, self.dev_test) other_data2.createOtherUser('*****@*****.**') other_data2.createProfile() other_data2.notificationSettings() invitation.delete() override[ 'link_id'] = '[email protected], [email protected]' other_data.notificationSettings() response, properties = self.modelPost(url, GSoCRequest, override) self.assertEmailSent(to=other_data.profile.email, n=1) invitations = GSoCRequest.all().fetch(2) self.assertEqual(2, len(invitations)) invitation = invitations[0] properties.pop('link_id') self.assertPropertiesEqual(properties, invitation) properties['user'] = other_data2.user properties['parent'] = other_data2.user self.assertPropertiesEqual(properties, invitations[1]) # test withdraw/resubmit invite url = '/gsoc/invitation/%s/%s/%s' % (self.gsoc.key().name(), invitation.parent_key().name(), invitation.key().id()) other_data.notificationSettings(invite_handled=True) postdata = {'action': 'Withdraw'} response = self.post(url, postdata) self.assertResponseRedirect(response) invite = GSoCRequest.all().get() self.assertEqual('withdrawn', invite.status) self.assertEmailSent(to=other_data.profile.email, n=2) # test that you can resubmit postdata = {'action': 'Resubmit'} response = self.post(url, postdata) self.assertResponseRedirect(response) invite = GSoCRequest.all().get() self.assertEqual('pending', invite.status) self.assertEmailSent(to=other_data.profile.email, n=3)
def createMentor(self): """Creates a new mentor. """ profile_helper = GSoCProfileHelper(self.gsoc, self.dev_test) profile_helper.createOtherUser('*****@*****.**') self.mentor = profile_helper.createMentor(self.org)
def createStudent(self, email, program): profile_helper = GSoCProfileHelper(program, dev_test=False) profile_helper.createOtherUser(email) student = profile_helper.createStudent() return student