def testListProjects(self): self.data.createHost() self.timeline.studentsAnnounced() url = '/gsoc/admin/projects/' + self.org.key().name() response = self.get(url) self.assertProjectsPage(response) response = self.getListResponse(url, 0) self.assertIsJsonResponse(response) data = response.context['data'][''] self.assertEqual(0, len(data)) # test list with student's proposal self.mentor = GSoCProfileHelper(self.gsoc, self.dev_test) self.mentor.createMentor(self.org) self.data.createStudentWithProjects(self.org, self.mentor.profile, 1) response = self.getListResponse(url, 0) self.assertIsJsonResponse(response) data = response.context['data'][''] self.assertEqual(1, len(data)) # rendered inside cbox iframe url += '?cbox=true' response = self.get(url) self.assertProjectsPage(response)
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
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
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)
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)
class ProjectListTest(GSoCDjangoTestCase): """Tests project list page. """ def setUp(self): self.init() def assertProjectTemplatesUsed(self, response): """Asserts that all the templates from the dashboard were used. """ self.assertGSoCTemplatesUsed(response) self.assertTemplateUsed(response, "v2/modules/gsoc/projects_list/base.html") self.assertTemplateUsed(response, "v2/modules/gsoc/projects_list/_project_list.html") def testListProjects(self): self.timeline.studentsAnnounced() url = "/gsoc/projects/list/" + self.gsoc.key().name() response = self.get(url) self.assertProjectTemplatesUsed(response) response = self.getListResponse(url, 0) self.assertIsJsonResponse(response) data = response.context["data"][""] self.assertEqual(0, len(data)) self.mentor = GSoCProfileHelper(self.gsoc, self.dev_test) self.mentor.createMentor(self.org) self.data.createStudentWithProject(self.org, self.mentor.profile) response = self.getListResponse(url, 0) self.assertIsJsonResponse(response) data = response.context["data"][""] self.assertEqual(1, len(data))
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)
class ProjectListTest(GSoCDjangoTestCase): """Tests project list page. """ def setUp(self): self.init() def assertProjectTemplatesUsed(self, response): """Asserts that all the templates from the dashboard were used. """ self.assertGSoCTemplatesUsed(response) self.assertTemplateUsed(response, 'v2/modules/gsoc/projects_list/base.html') self.assertTemplateUsed( response, 'v2/modules/gsoc/projects_list/_project_list.html') def testListProjects(self): self.timeline.studentsAnnounced() url = '/gsoc/projects/list/' + self.gsoc.key().name() response = self.get(url) self.assertProjectTemplatesUsed(response) response = self.getListResponse(url, 0) self.assertIsJsonResponse(response) data = response.context['data'][''] self.assertEqual(0, len(data)) self.mentor = GSoCProfileHelper(self.gsoc, self.dev_test) self.mentor.createMentor(self.org) self.data.createStudentWithProject(self.org, self.mentor.profile) response = self.getListResponse(url, 0) self.assertIsJsonResponse(response) data = response.context['data'][''] self.assertEqual(1, len(data))
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)
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))
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)
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)
def createMentor(self): """Creates a mentor for organization. """ self.mentor = GSoCProfileHelper(self.gsoc, self.dev_test) self.mentor.createOtherUser('*****@*****.**') self.mentor.createMentor(self.org) self.mentor.notificationSettings()
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()
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()
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)
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)
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)
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)
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)
class ProjectsPageTest(GSoCDjangoTestCase): """Test projects list for admin """ def setUp(self): self.init() def assertProjectsPage(self, response): """Asserts that all the templates from the accepted projects list were used and all contexts were passed. """ self.assertTrue('base_layout' in response.context) self.assertTrue('cbox' in response.context) if response.context['cbox']: self.assertGSoCColorboxTemplatesUsed(response) self.assertEqual(response.context['base_layout'], 'v2/modules/gsoc/base_colorbox.html') else: self.assertGSoCTemplatesUsed(response) self.assertEqual(response.context['base_layout'], 'v2/modules/gsoc/base.html') self.assertTemplateUsed(response, 'v2/modules/gsoc/admin/list.html') self.assertTemplateUsed(response, 'v2/modules/gsoc/admin/_projects_list.html') def testListProjects(self): self.data.createHost() self.timeline.studentsAnnounced() url = '/gsoc/admin/projects/' + self.org.key().name() response = self.get(url) self.assertProjectsPage(response) response = self.getListResponse(url, 0) self.assertIsJsonResponse(response) data = response.context['data'][''] self.assertEqual(0, len(data)) # test list with student's proposal self.mentor = GSoCProfileHelper(self.gsoc, self.dev_test) self.mentor.createMentor(self.org) self.data.createStudentWithProjects(self.org, self.mentor.profile, 1) response = self.getListResponse(url, 0) self.assertIsJsonResponse(response) data = response.context['data'][''] self.assertEqual(1, len(data)) # rendered inside cbox iframe url += '?cbox=true' response = self.get(url) self.assertProjectsPage(response)
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)
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)
def init(self): """Performs test setup. Sets the following attributes: program_helper: a GSoCProgramHelper instance gsoc/program: a GSoCProgram instance site: a Site instance org: a GSoCOrganization instance org_app: a OrgAppSurvey instance timeline: a GSoCTimelineHelper instance data: a GSoCProfileHelper instance """ from tests.program_utils import GSoCProgramHelper from tests.timeline_utils import GSoCTimelineHelper from tests.profile_utils import GSoCProfileHelper super(GSoCTestCase, self).init() self.program_helper = GSoCProgramHelper() self.founder = self.program_helper.createFounder() self.sponsor = self.program_helper.createSponsor() self.gsoc = self.program = self.program_helper.createProgram() self.site = self.program_helper.createSite() self.org = self.program_helper.createOrg() self.org_app = self.program_helper.createOrgApp() self.timeline = GSoCTimelineHelper(self.gsoc.timeline, self.org_app) self.data = GSoCProfileHelper(self.gsoc, self.dev_test)
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
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)
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)
def init(self): """Performs test setup. Sets the following attributes: dev_test: True iff DEV_TEST is in environment gsoc: a GSoCProgram instance org_app: a OrgAppSurvey instance org: a GSoCOrganization instance timeline: a TimelineHelper instance data: a GSoCProfileHelper instance """ from soc.models.site import Site from soc.models.document import Document from soc.modules.gsoc.models.program import GSoCProgram from soc.modules.gsoc.models.timeline import GSoCTimeline from soc.modules.gsoc.models.organization import GSoCOrganization from soc.modules.seeder.logic.providers.string import DocumentKeyNameProvider from soc.models.org_app_survey import OrgAppSurvey from tests.timeline_utils import TimelineHelper from tests.profile_utils import GSoCProfileHelper self.dev_test = 'DEV_TEST' in os.environ properties = { 'timeline': self.seed(GSoCTimeline, {}), 'status': 'visible', 'apps_tasks_limit': 20 } self.gsoc = self.seed(GSoCProgram, properties) properties = { 'prefix': 'gsoc_program', 'scope': self.gsoc, 'read_access': 'public', 'key_name': DocumentKeyNameProvider(), } document = self.seed(Document, properties=properties) self.gsoc.about_page = document self.gsoc.events_page = document self.gsoc.help_page = document self.gsoc.connect_with_us_page = document self.gsoc.privacy_policy = document self.gsoc.put() self.site = Site(key_name='site', link_id='site', active_program=self.gsoc) self.site.put() properties = {'scope': self.gsoc} self.org_app = self.seed(OrgAppSurvey, properties) properties = {'scope': self.gsoc, 'status': 'active'} self.org = self.seed(GSoCOrganization, properties) self.timeline = TimelineHelper(self.gsoc.timeline, self.org_app) self.data = GSoCProfileHelper(self.gsoc, self.dev_test)
def testListProjects(self): self.timeline.studentsAnnounced() url = '/gsoc/projects/list/' + self.gsoc.key().name() response = self.get(url) self.assertProjectTemplatesUsed(response) response = self.getListResponse(url, 0) self.assertIsJsonResponse(response) data = response.context['data'][''] self.assertEqual(0, len(data)) self.mentor = GSoCProfileHelper(self.gsoc, self.dev_test) self.mentor.createMentor(self.org) self.data.createStudentWithProject(self.org, self.mentor.profile) response = self.getListResponse(url, 0) self.assertIsJsonResponse(response) data = response.context['data'][''] self.assertEqual(1, len(data))
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 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 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 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)
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()
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)
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 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 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 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