コード例 #1
0
    def test_projects_count_add_project(self):
        project_0 = ProjectFactory()
        self.assertEqual(self.partner_0.projects.count(), 0)
        self.assertEqual(self.partner_1.projects.count(), 0)
        self.assertEqual(self.partner_2.projects.count(), 0)

        self.partner_0.projects.add(project_0)

        self.assertEqual(self.partner_1.projects.count(), 0)
        self.assertEqual(self.partner_2.projects.count(), 0)

        self.assertEqual(self.partner_0.projects.count(), 1)
        self.assertEqual(self.partner_0.projects.get(id=project_0.id),
                         project_0)

        project_1 = ProjectFactory()

        self.partner_1.projects.add(project_1)

        self.assertEqual(self.partner_0.projects.count(), 1)
        self.assertEqual(self.partner_0.projects.get(id=project_0.id),
                         project_0)
        self.assertEqual(self.partner_1.projects.count(), 1)
        self.assertEqual(self.partner_1.projects.get(id=project_1.id),
                         project_1)

        self.assertEqual(self.partner_2.projects.count(), 0)
コード例 #2
0
    def test_projects_with_multiple_partners(self):
        project_0 = ProjectFactory()

        self.partner_0.projects.add(project_0)
        self.partner_1.projects.add(project_0)

        self.assertEqual(self.partner_0.projects.count(), 1)
        self.assertEqual(self.partner_0.projects.get(id=project_0.id),
                         project_0)
        self.assertEqual(self.partner_1.projects.count(), 1)
        self.assertEqual(self.partner_1.projects.get(id=project_0.id),
                         project_0)
        self.assertEqual(self.partner_2.projects.count(), 0)

        project_1 = ProjectFactory()

        self.partner_1.projects.add(project_1)
        self.partner_2.projects.add(project_1)

        self.assertEqual(self.partner_0.projects.count(), 1)
        self.assertEqual(self.partner_0.projects.get(id=project_0.id),
                         project_0)
        self.assertEqual(self.partner_1.projects.count(), 2)
        self.assertEqual(self.partner_1.projects.get(id=project_0.id),
                         project_0)
        self.assertEqual(self.partner_1.projects.get(id=project_1.id),
                         project_1)
        self.assertEqual(self.partner_2.projects.count(), 1)
        self.assertEqual(self.partner_2.projects.get(id=project_1.id),
                         project_1)
コード例 #3
0
    def test_projects_count_add_new_after_remove_project(self):
        project_0 = ProjectFactory()

        self.partner_0.projects.add(project_0)
        self.partner_0.projects.remove(project_0)

        project_1 = ProjectFactory()

        self.partner_0.projects.add(project_1)

        self.assertEqual(self.partner_0.projects.count(), 1)
        self.assertEqual(self.partner_0.projects.get(id=project_1.id),
                         project_1)
コード例 #4
0
    def setUpClass(cls):
        super().setUpClass()
        cls.project_0_categories = []
        cls.project_1_categories = ["Testing"]

        cls.project_0 = ProjectFactory(project_category = ';'.join(cls.project_0_categories))
        cls.project_1 = ProjectFactory(project_category = ';'.join(cls.project_1_categories))

        cls.student_A = StudentFactory()
        cls.student_B = StudentFactory()

        cls.application_1 = ApplicationFactory(project=cls.project_0, student_id=cls.student_A.id)
        cls.application_2 = ApplicationFactory(project=cls.project_1, student_id=cls.student_B.id)
コード例 #5
0
    def test_access_nonexistent_project(self):
        self.client.login(username=self.user.username, password=self.password)
        user = auth.get_user(self.client)
        self.assertTrue(user.is_authenticated)

        config.APP_LIMIT = 10
        config.SCHOLAR_APP_LIMIT = 10
        config.APPLICATIONS_OPEN = True

        project = ProjectFactory()
        project_name = project.project_name
        project.delete()

        response = self.client.get(reverse('apply', args=(project_name, )))
        self.assertEqual(response.status_code, 404)
コード例 #6
0
    def setUpClass(cls):
        super().setUpClass()
        cls.project_0_categories = []
        cls.project_1_categories = ["Testing"]
        cls.project_2_categories = ["Testing", "Data Science"]

        cls.project_0 = ProjectFactory(
            project_category=';'.join(cls.project_0_categories))
        cls.project_1 = ProjectFactory(
            project_category=';'.join(cls.project_1_categories))
        cls.project_2 = ProjectFactory(
            project_category=';'.join(cls.project_2_categories))

        cls.student_A = StudentFactory()
        cls.student_B = StudentFactory()
コード例 #7
0
    def test_status_summary_semester(self):
        projCt = random.randint(1, 10)
        appCt = random.randint(1, 10)

        projList = []
        appList = []

        for i in range(0, projCt):
            projList.append(
                ProjectFactory(
                    semester=self.semesters[random.randint(1, self.semesterCt)
                                            - 1]))

        for i in range(0, appCt):
            appList.append(
                ApplicationFactory(project=projList[random.randint(1, projCt) -
                                                    1]))

        self.user_login(self.admin)
        self.selenium.get(
            '%s%s' % (self.live_server_url, reverse('admin:status_summary')))

        # default
        groupType = 'student'
        applicant = 'students'
        # click select all as default is none
        self.selenium.find_element_by_id("showSelect").click()
        for semester in self.semesters:
            self.selenium.get(
                '%s%s' %
                (self.live_server_url, reverse('admin:status_summary')))
            self.page_validation(groupType, semester, applicant, appList, None)
コード例 #8
0
    def test_status_summary_group_random_proj(self):
        studentCt = random.randint(1, 10)
        projCt = random.randint(1, 10)
        projList = []
        studentList = []
        appList = []

        for i in range(0, projCt):
            projList.append(ProjectFactory())

        for i in range(0, studentCt):
            studentList.append(StudentFactory())

            selectedProjCt = random.randint(1, projCt) - 1
            for projNum in random.sample(range(0, projCt), selectedProjCt):
                appList.append(
                    ApplicationFactory(project=projList[projNum],
                                       student=studentList[i]))

        self.user_login(self.admin)
        self.selenium.get(
            '%s%s' % (self.live_server_url, reverse('admin:status_summary')))

        # default
        applicant = 'students'
        semester = self.short_current_semester
        filter = "all"
        for groupType in self.groupTypes:
            self.selenium.get(
                '%s%s' %
                (self.live_server_url, reverse('admin:status_summary')))
            self.page_validation(groupType, semester, applicant, appList, None)
コード例 #9
0
    def test_access_project_apply_edit_profile_as_admin(self):
        config.CURRENT_SEMESTER = self.current_semester
        projCt = random.randint(1, 10)
        projList = []
        for i in range(0, projCt):
            projList.append(ProjectFactory())
        selectedProjName = projList[0].project_name

        self.selenium.get('%s%s' % (self.live_server_url, reverse('list_projects')))
        self.page_validation(projList)

        self.user_login(self.admin,selectedProjName)
        signupRedirect = self.live_server_url + "/accounts/google/login/"
        self.assertEqual(signupRedirect,self.selenium.current_url)
        self.selenium.get('%s%s' % (self.live_server_url,reverse('apply',kwargs={'project_name':selectedProjName})))
        # Edit profile
        self.assertTrue(self.selenium.find_elements_by_xpath('//h3')[0].text == 'Edit Profile')

        student = StudentFactory(email_address=self.admin.email)
        ifield = ["first_name", "last_name", "student_id", "major", "resume_link", "general_question",  "additional_skills"]
        for j in range(0, len(ifield)):
            self.selenium.find_element_by_name(ifield[j]).send_keys(getattr(student, ifield[j]))

        bfield = ["college", "year"]
        for j in range(0, len(bfield)):
            Select(self.selenium.find_element_by_name(bfield[j])).select_by_value(getattr(student, bfield[j]))

        skillset = {}
        for skill in Student.default_skills:
            skillset[skill] = random.choice(list(filter(None, Student.skill_levels_options.keys())))
        for j in skillset:
            Select(self.selenium.find_element_by_name(j)).select_by_value(skillset[j])

        self.selenium.find_element_by_xpath("//input[@type='submit']").click()
        self.basic_information_page_validation(self.admin, student, skillset)
コード例 #10
0
    def test_access_roster_partner_with_projects_login_not_reviewable(self):
        projCt = random.randint(1, 10)
        partnerProjList = []
        partner = UserFactory(password=self.password)
        partner_obj = PartnerFactory(email_address=partner.email)

        for i in range(0, projCt):
            partnerProjList.append(
                PartnerProjectInfoFactory(project=ProjectFactory(),
                                          partner=partner_obj))

        config.APPLICATIONS_REVIEWABLE = False
        self.user_login(partner)

        self.assertEqual(self.logonRedirect, self.selenium.current_url)

        self.selenium.get(
            '%s%s' %
            (self.live_server_url, reverse('display_student_team_roster')))

        expectedMsgs = ["Partners view the roster in applications."]
        for i, x in enumerate(
                self.selenium.find_elements_by_class_name("alert-info")):
            self.assertEqual(x.text, expectedMsgs[i])
        expectedMsg = "Applications are not yet open for review. If you believe you have received this message in error, please email [email protected]."
        self.assertEqual(
            expectedMsg,
            self.selenium.find_element_by_id("application-questions").text)
コード例 #11
0
    def test_access_get_profile_as_student(self):

        student = UserFactory(password=self.password)
        student_obj = StudentFactory(email_address=student.email,
                                     first_name=student.first_name,
                                     last_name=student.last_name)

        # add application associate to the student
        appCt = random.randint(1, 10)
        appList = []

        for i in range(1, appCt):
            appList.append(
                ApplicationFactory(project=ProjectFactory(),
                                   student=student_obj))

        self.user_login(student)

        # need to reload the page again for now
        self.selenium.get('%s%s' %
                          (self.live_server_url, reverse('get_profile')))

        # show Basic Information directly information page
        self.basic_information_page_validation(student, student_obj,
                                               student_obj._skills)
コード例 #12
0
    def test_status_summary_semester(self):
        projCt = random.randint(1, 10)
        appCt = random.randint(1, 10)

        projList = []
        appList = []

        for i in range(0, projCt):
            projList.append(
                ProjectFactory(
                    semester=self.semesters[random.randint(1, self.semesterCt)
                                            - 1]))

        for i in range(0, appCt):
            appList.append(
                ApplicationFactory(project=projList[random.randint(1, projCt) -
                                                    1]))

        self.client.login(username=self.admin.username, password=self.password)
        user = auth.get_user(self.client)
        self.assertTrue(user.is_authenticated)

        response = self.client.get(reverse('admin:status_summary'))
        self.assertEqual(response.status_code, 200)

        # default value
        groupType = 'student'
        applicant = 'students'
        for semester in self.semesters:
            response = self.client.get(f'/admin/status_summary/?semester=' +
                                       semester + self.default_link_values)
            self.response_validation(response, groupType, semester, applicant,
                                     appList)
コード例 #13
0
    def test_access_application_as_user_with_profile(self):
        self.user_login(self.user)
        self.selenium.get('%s%s' % (self.live_server_url, reverse('app_index')))
        # Create profile
        student = StudentFactory(email_address=self.user.email)
        ifield = ["first_name", "last_name", "student_id", "major", "resume_link", "general_question", "additional_skills"]
        for j in range(0, len(ifield)):
            self.selenium.find_element_by_name(ifield[j]).send_keys(getattr(student, ifield[j]))

        bfield = ["college", "year"]
        for j in range(0, len(bfield)):
            Select(self.selenium.find_element_by_name(bfield[j])).select_by_value(getattr(student, bfield[j]))

        skillset = {}
        for skill in Student.default_skills:
            skillset[skill] = random.choice(list(filter(None, Student.skill_levels_options.keys())))
        for j in skillset:
            Select(self.selenium.find_element_by_name(j)).select_by_value(skillset[j])

        self.selenium.find_element_by_xpath("//input[@type='submit']").click()
        self.basic_information_page_validation(self.user, student, skillset)


        # add application associate to the student
        appCt = random.randint(1, 10)
        answerList =[]

        for i in range(0, appCt):
            proj = ProjectFactory()
            application = ApplicationFactory(project=proj, student=student)
            answerList.append(AnswerFactory(student=student, application=application))

        self.selenium.get('%s%s' % (self.live_server_url, reverse('app_index')))
        self.application_page_validation(answerList)
コード例 #14
0
    def test_status_summary_group_random_app(self):
        appCt = random.randint(1, 10)
        projCt = random.randint(1, 10)
        projList = []
        appList = []

        for i in range(0, projCt):
            projList.append(ProjectFactory())

        for i in range(0, appCt):
            appList.append(
                ApplicationFactory(project=projList[random.randint(1, projCt) -
                                                    1]))

        self.client.login(username=self.admin.username, password=self.password)
        user = auth.get_user(self.client)
        self.assertTrue(user.is_authenticated)

        response = self.client.get(reverse('admin:status_summary'))
        self.assertEqual(response.status_code, 200)

        #default applicant
        applicant = 'students'
        for groupType in self.groupTypes:
            response = self.client.get(f'/admin/status_summary/?group=' +
                                       groupType)
            current_sem = [
                item for item in response.context.get("semester_support")
                if item[1] == config.CURRENT_SEMESTER
            ]
            semester = current_sem[0][0]
            self.response_validation(response, groupType, semester, applicant,
                                     appList)
コード例 #15
0
    def setUpClass(cls):
        super().setUpClass()
        cls.password = '******'

        cls.user = UserFactory(password=cls.password)

        cls.partner = UserFactory(password=cls.password)
        cls.partner_obj = PartnerFactory(email_address=cls.partner.email)

        cls.student = UserFactory(password=cls.password)
        cls.student_obj = StudentFactory(email_address=cls.student.email)

        cls.admin = AdminFactory()

        cls.project = ProjectFactory()

        #default student
        cls.groupTypes = ['student', 'project']
        #default current Semester (config.CURRENT_SEMESTER)
        cls.semesters = [s[0] for s in Semester.choices]
        cls.semesterCt = len(cls.semesters)
        #default ALL IN
        cls.filters = ['Sub', 'Rni', 'Int', 'Rwi', 'Ofs', 'Ofr', 'Ofa']
        cls.filterTypes = ['ANY', 'ALL']
        #default 'students'
        cls.applicantTypes = ['students', 'scholars']
        cls.default_link_values = '&any_all=ANY&Sub=True&Rni=True&Int=True&Rwi=True&Ofs=True&Ofr=True&Ofa=True'
コード例 #16
0
    def test_access_list_projects_semester_random_app_threshold(self):
        projCt = random.randint(5, 10)
        appCt = random.randint(10, 30)
        projList = []
        appList = []

        for i in range(0, projCt):
            projList.append(
                ProjectFactory(semester=self.short_current_semester))

        for i in range(0, appCt):
            projNum = random.randint(1, projCt)
            appList.append(ApplicationFactory(project=projList[projNum - 1]))

        self.selenium.get('%s%s' %
                          (self.live_server_url, reverse('list_projects')))

        # Test 5 different threshold settings
        for threshold in range(5):
            config.HIDE_PROJECT_APPLICATION_THRESHOLD = threshold
            self.selenium.get('%s%s' %
                              (self.live_server_url, reverse('list_projects')))
            self.page_validation(projList, appList, threshold)

        config.HIDE_PROJECT_APPLICATION_THRESHOLD = 10
コード例 #17
0
    def test_max_applications_data_scholar(self):
        other_project = ProjectFactory()

        ApplicationFactory(student=self.ds_student_obj, project=other_project)

        self.client.login(username=self.ds_student.username,
                          password=self.password)
        user = auth.get_user(self.client)
        self.assertTrue(user.is_authenticated)

        config.APP_LIMIT = 10
        config.SCHOLAR_APP_LIMIT = 0
        config.APPLICATIONS_OPEN = True

        project_name = self.project.project_name
        response = self.client.get(reverse('apply', args=(project_name, )))
        self.assertRedirects(response,
                             '/projects',
                             status_code=302,
                             target_status_code=301,
                             fetch_redirect_response=True)
        messages = list(get_messages(response.wsgi_request))
        message = 'You have already applied to 0 projects.'
        self.assertEqual(len(messages), 1)
        self.assertEqual(str(messages[0]), message)
コード例 #18
0
 def test_access_list_projects_current_semester(self):
     config.HIDE_PROJECT_APPLICATION_THRESHOLD = 10
     projCt = random.randint(5, 10)
     projList = []
     for i in range(0, projCt):
         projList.append(
             ProjectFactory(semester=self.short_current_semester))
     self.selenium.get('%s%s' %
                       (self.live_server_url, reverse('list_projects')))
     self.page_validation(projList)
コード例 #19
0
    def test_status_summary_group_semester_applicant_partner_filter_random_status(
            self):
        studentCt = random.randint(1, 15)
        projCt = random.randint(1, 15)
        partnerProjCt = random.randint(1, 15)
        projList = []
        studentList = []
        appList = []
        partnerProjectList = []

        for i in range(0, projCt):
            projList.append(
                ProjectFactory(
                    semester=self.semesters[random.randint(1, self.semesterCt)
                                            - 1]))

        for i in range(0, partnerProjCt):
            partnerProjectList.append(
                PartnerProjectInfoFactory(
                    project=projList[random.randint(1, projCt) - 1]))

        for i in range(0, studentCt):
            if i < studentCt // 2:
                studentList.append(StudentFactory())
            else:
                ds = DataScholarFactory()
                studentList.append(
                    StudentFactory(email_address=ds.email_address))

            selectedProjCt = random.randint(1, projCt) - 1
            for projNum in random.sample(range(0, projCt), selectedProjCt):
                appList.append(
                    ApplicationFactory(project=projList[projNum],
                                       student=studentList[i],
                                       status=self.filters[random.randint(
                                           1,
                                           len(self.filters) - 1)].upper()))

        self.user_login(self.admin)
        self.selenium.get(
            '%s%s' % (self.live_server_url, reverse('admin:status_summary')))
        for groupType in self.groupTypes:
            for semester in self.semesters:
                for applicant in self.applicantTypes:
                    for filterType in self.filterTypes:
                        self.selenium.get('%s%s' %
                                          (self.live_server_url,
                                           reverse('admin:status_summary')))
                        self.page_validation(
                            groupType, semester, applicant, appList,
                            partnerProjectList, filterType,
                            random.sample(
                                self.filters,
                                random.randint(1,
                                               len(self.filters) - 1)))
コード例 #20
0
    def test_access_project_apply_no_login(self):
        config.CURRENT_SEMESTER = self.current_semester
        projCt = random.randint(1, 10)
        projList = []
        for i in range(0, projCt):
            projList.append(ProjectFactory())
        selectedProjName = projList[0].project_name

        self.selenium.get('%s%s' % (self.live_server_url, reverse('list_projects')))
        self.page_validation(projList, None)

        self.selenium.get('%s%s' % (self.live_server_url, reverse('apply', kwargs={'project_name':selectedProjName})))
        self.assertEqual(self.logonRedirect, self.selenium.current_url)
コード例 #21
0
    def test_access_application_login_as_student(self):
        # add application associate to the student
        appCt = random.randint(1, 10)
        answerList = []

        for i in range(0, appCt):
            proj = ProjectFactory()
            application = ApplicationFactory(project=proj, student=self.student_obj)
            answerList.append(AnswerFactory(student=self.student_obj, application=application))

        self.user_login(self.student)
        self.selenium.get('%s%s' % (self.live_server_url, reverse('app_index')))
        self.application_page_validation(answerList)
コード例 #22
0
    def setUpClass(cls):
        super().setUpClass()

        cls.password = '******'

        cls.user = UserFactory(password=cls.password)

        cls.partner = UserFactory(password=cls.password)
        cls.partner_obj = PartnerFactory(email_address=cls.partner.email)

        cls.student = UserFactory(password=cls.password)
        cls.student_obj = StudentFactory(email_address=cls.student.email)

        cls.project = ProjectFactory()
コード例 #23
0
    def test_access_archive_projects(self):
        config.CURRENT_SEMESTER = self.current_semester
        projCt = random.randint(1, 10)
        appCt = random.randint(1, 10)
        partnerCt = random.randint(1, 10)
        projList = []
        appList = []
        partnerList = []

        for i in range(0, projCt):
            projList.append(ProjectFactory(semester=self.semesters[random.randint(1, self.semesterCt)-1]))

        self.selenium.get('%s%s' % (self.live_server_url, reverse('index')))
        self.page_validation(projList)
コード例 #24
0
    def test_access_application_login_as_partner_not_reviewable(self):
        config.APPLICATIONS_REVIEWABLE = False

        projCt = random.randint(1, 10)
        partnerProjList = []

        for i in range(0, projCt):
            partnerProjList.append(PartnerProjectInfoFactory(project=ProjectFactory(), partner=self.partner_obj))

        self.user_login(self.partner)
        self.selenium.get('%s%s' % (self.live_server_url,reverse('app_index')))

        expectedMsg = "Applications are not yet open for review. If you believe you have received this message in error, please email [email protected]."
        self.assertEqual(expectedMsg, self.selenium.find_element_by_id("application-questions").text)
コード例 #25
0
    def test_access_student_signup_as_partner(self):

        partner = UserFactory(password=self.password)
        partner_obj = PartnerFactory(email_address=partner.email,
                                     first_name=partner.first_name,
                                     last_name=partner.last_name)

        projCt = random.randint(1, 10)
        partnerProjList = []

        for i in range(0, projCt):
            partnerProjList.append(
                PartnerProjectInfoFactory(project=ProjectFactory(),
                                          partner=partner_obj))

        self.user_login(partner)

        self.selenium.get('%s%s' %
                          (self.live_server_url, reverse('student_signup')))
        self.assertTrue(
            self.selenium.find_elements_by_xpath('//h3')[0].text ==
            'Edit Profile')

        student = StudentFactory(email_address=partner.email)
        ifield = [
            "first_name", "last_name", "student_id", "major", "resume_link",
            "general_question", "additional_skills"
        ]
        for j in range(0, len(ifield)):
            self.selenium.find_element_by_name(ifield[j]).send_keys(
                getattr(student, ifield[j]))

        bfield = ["college", "year"]
        for j in range(0, len(bfield)):
            Select(self.selenium.find_element_by_name(
                bfield[j])).select_by_value(getattr(student, bfield[j]))

        skillset = {}
        for skill in Student.default_skills:
            skillset[skill] = random.choice(
                list(filter(None, Student.skill_levels_options.keys())))
        for j in skillset:
            Select(self.selenium.find_element_by_name(j)).select_by_value(
                skillset[j])

        self.selenium.find_element_by_xpath("//input[@type='submit']").click()

        #show personal information page
        self.personal_information_page_validation(partner, partnerProjList)
コード例 #26
0
    def test_access_roster_partner_with_projects_login_reviewable(self):
        config.APPLICATIONS_REVIEWABLE = True
        app_status = list(self.app_status_map.keys())

        projCt = random.randint(1, 10)
        appCt = random.randint(10, 20)
        studentCt = random.randint(1, 20)
        partnerProjList = []
        studentList = []
        answerList = []
        appList = []

        for i in range(0, studentCt):
            studentList.append(StudentFactory())

        for i in range(0, projCt):
            partnerProjList.append(
                PartnerProjectInfoFactory(project=ProjectFactory(),
                                          partner=self.partner_obj))

        pair = []
        for i in range(0, appCt):
            comb = (random.randint(0, projCt - 1),
                    random.randint(0, studentCt - 1))
            if comb in pair:
                continue
            pair.append(comb)

            proj = partnerProjList[comb[0]].project
            student_obj = studentList[comb[1]]
            status = app_status[random.randint(0, len(app_status) - 1)]
            application = ApplicationFactory(project=proj,
                                             student=student_obj,
                                             status=status)
            appList.append(application)
            answerList.append(
                AnswerFactory(student=self.student_obj,
                              application=application))

        self.user_login(self.partner)
        self.selenium.get('%s%s' %
                          (self.live_server_url, reverse('app_index')))
        expectedMsg = "Team Roster"
        self.assertEqual(expectedMsg,
                         self.selenium.find_element_by_id("team-roster").text)
        self.team_roster_page_validation(self.partner_obj, partnerProjList,
                                         appList)
コード例 #27
0
    def test_status_summary_group_semester_applicant_random_status(self):
        studentCt = random.randint(1, 10)
        projCt = random.randint(1, 10)
        projList = []
        studentList = []
        appList = []

        for i in range(0, projCt):
            projList.append(
                ProjectFactory(
                    semester=self.semesters[random.randint(1, self.semesterCt)
                                            - 1]))

        for i in range(0, studentCt):
            if i < studentCt // 2:
                studentList.append(StudentFactory())
            else:
                ds = DataScholarFactory()
                studentList.append(
                    StudentFactory(email_address=ds.email_address))

            selectedProjCt = random.randint(1, projCt) - 1
            for projNum in random.sample(range(0, projCt), selectedProjCt):
                appList.append(
                    ApplicationFactory(project=projList[projNum],
                                       student=studentList[i],
                                       status=self.filters[random.randint(
                                           1,
                                           len(self.filters) - 1)].upper()))

        self.client.login(username=self.admin.username, password=self.password)
        user = auth.get_user(self.client)
        self.assertTrue(user.is_authenticated)

        response = self.client.get(reverse('admin:status_summary'))
        self.assertEqual(response.status_code, 200)

        for groupType in self.groupTypes:
            for semester in self.semesters:
                for applicant in self.applicantTypes:
                    response = self.client.get(
                        f'/admin/status_summary/?group=' + groupType +
                        '&semester=' + semester + '&applicant=' + applicant +
                        self.default_link_values)
                    self.response_validation(response, groupType, semester,
                                             applicant, appList)
コード例 #28
0
    def test_access_project_apply_edit_profile_apply_as_user(self):
        config.CURRENT_SEMESTER = self.current_semester
        projCt = random.randint(1, 10)
        projList = []
        for i in range(0, projCt):
            projList.append(ProjectFactory())
        selectedProjName = projList[0].project_name

        self.selenium.get('%s%s' % (self.live_server_url, reverse('list_projects')))
        self.page_validation(projList)

        self.user_login(self.user, selectedProjName)
        signupRedirect = self.live_server_url + "/accounts/google/login/"
        self.assertEqual(signupRedirect, self.selenium.current_url)
        self.selenium.get('%s%s' % (self.live_server_url, reverse('apply', kwargs={'project_name':selectedProjName})))
        # Edit profile
        self.assertTrue(self.selenium.find_elements_by_xpath('//h3')[0].text == 'Edit Profile')

        student = StudentFactory(email_address=self.user.email)
        ifield = ["first_name", "last_name", "student_id", "major", "resume_link", "general_question",  "additional_skills"]
        for j in range(0, len(ifield)):
            self.selenium.find_element_by_name(ifield[j]).send_keys(getattr(student, ifield[j]))

        bfield = ["college", "year"]
        for j in range(0, len(bfield)):
            Select(self.selenium.find_element_by_name(bfield[j])).select_by_value(getattr(student, bfield[j]))

        skillset = {}
        for skill in Student.default_skills:
            skillset[skill] = random.choice(list(filter(None, Student.skill_levels_options.keys())))
        for j in skillset:
            Select(self.selenium.find_element_by_name(j)).select_by_value(skillset[j])

        self.selenium.find_element_by_xpath("//input[@type='submit']").click()
        # may fail due to additonal skills issue
        #self.basic_information_page_validation(self.user, student, skillset)

        self.selenium.get('%s%s' % (self.live_server_url,reverse('apply', kwargs={'project_name':selectedProjName})))
        # msg_html = BeautifulSoup(self.selenium.find_element_by_id("messages").get_attribute('innerHTML'), features="html.parser")
        #expectedMsg = "Applications are currently closed. If you believe you have received this message in error, please email [email protected]."
        # expectedMsg = "Please make sure your responses are finalized as you will not be able to edit your responses once you submit."
        # self.assertEqual(expectedMsg,msg_html.find("div").text)

        msg_html = BeautifulSoup(self.selenium.find_element_by_class_name("mb-5").get_attribute('innerHTML'), features="html.parser")
        expectedMsg = "Please make sure your responses are finalized as you will not be able to edit your responses once you submit."
        self.assertEqual(expectedMsg,msg_html.find("p").text)
コード例 #29
0
    def test_access_project_apply_admin_login(self):
        config.CURRENT_SEMESTER = self.current_semester
        projCt = random.randint(1, 10)
        projList = []
        for i in range(0, projCt):
            projList.append(ProjectFactory())
        selectedProjName = projList[0].project_name

        self.selenium.get('%s%s' % (self.live_server_url, reverse('list_projects')))
        self.page_validation(projList)

        self.user_login(self.admin,selectedProjName)
        signupRedirect = self.live_server_url + "/accounts/google/login/"
        self.assertEqual(signupRedirect,self.selenium.current_url)
        self.selenium.get('%s%s' % (self.live_server_url,reverse('apply',kwargs={'project_name':selectedProjName})))
        # Edit profile
        self.assertTrue(self.selenium.find_elements_by_xpath('//h3')[0].text == 'Edit Profile')
コード例 #30
0
    def test_status_summary_group_semester_applicant_random_status(self):
        studentCt = random.randint(1, 10)
        projCt = random.randint(1, 10)
        projList = []
        studentList = []
        appList = []

        for i in range(0, projCt):
            projList.append(
                ProjectFactory(
                    semester=self.semesters[random.randint(1, self.semesterCt)
                                            - 1]))

        for i in range(0, studentCt):
            if i < studentCt // 2:
                studentList.append(StudentFactory())
            else:
                ds = DataScholarFactory()
                studentList.append(
                    StudentFactory(email_address=ds.email_address))

            selectedProjCt = random.randint(1, projCt) - 1
            for projNum in random.sample(range(0, projCt), selectedProjCt):
                appList.append(
                    ApplicationFactory(project=projList[projNum],
                                       student=studentList[i],
                                       status=self.filters[random.randint(
                                           1,
                                           len(self.filters) - 1)].upper()))

        self.user_login(self.admin)
        self.selenium.get(
            '%s%s' % (self.live_server_url, reverse('admin:status_summary')))
        # click select all as default is none
        self.selenium.find_element_by_id("showSelect").click()
        for groupType in self.groupTypes:
            for semester in self.semesters:
                for applicant in self.applicantTypes:
                    self.selenium.get('%s%s' %
                                      (self.live_server_url,
                                       reverse('admin:status_summary')))
                    self.page_validation(groupType, semester, applicant,
                                         appList, None)