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)))
Example #2
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)
Example #3
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()
Example #4
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'
    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)
    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)
Example #7
0
    def test_access_student_signup_edit_profile_as_admin(self):
        self.user_login(self.admin)
        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=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)
    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)
    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)
Example #10
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)
Example #11
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.logon_redirect = "/profile/login?next=/profile/"
    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)
Example #13
0
    def test_access_edit_student_profile_as_student_no_update(self):

        student = UserFactory(password=self.password)
        student_obj = StudentFactory(email_address=student.email,
                                     first_name=student.first_name,
                                     last_name=student.last_name)
        print(student_obj._skills)
        print(student_obj.to_dict()['skills'])

        # 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('edit_student_profile')))

        self.assertTrue(
            self.selenium.find_elements_by_xpath('//h3')[0].text ==
            'Edit Profile')

        # student may not fill up all the skills. UI doesn't allow non-selected skill Level;
        # update all for now
        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])

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

        self.basic_information_page_validation(student, student_obj, skillset)
Example #14
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.ds_student = UserFactory(password=cls.password)
        cls.ds_obj = DataScholarFactory(email_address=cls.ds_student.email)
        cls.ds_student_obj = StudentFactory(email_address=cls.ds_student.email)

        cls.admin = AdminFactory()

        cls.project = ProjectFactory()
    def setUp(cls):
        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()
Example #16
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)
    def setUp(cls):
        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(password=cls.password)

        cls.sem_map = {k:v for k, v in Project.sem_mapping.items()}
        cls.app_status_map = {k:v for k, v in Application.app_status_mapping.items()}
Example #18
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)
    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)
Example #20
0
    def test_access_student_signup_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)

        self.selenium.get('%s%s' %
                          (self.live_server_url, reverse('student_signup')))
Example #21
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.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 = 'students'
        for groupType in self.groupTypes:
            response = self.client.get(f'/admin/status_summary/?group=' +
                                       groupType)
            self.assertEqual(response.status_code, 200)

            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)
Example #22
0
    def test_status_summary_group_semester(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):
            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.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:
            for semester in self.semesters:
                response = self.client.get(f'/admin/status_summary/?group=' +
                                           groupType + '&semester=' +
                                           semester + self.default_link_values)
                self.response_validation(response, groupType, semester,
                                         applicant, appList)
    def test_status_summary_group_semester(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):
            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
        applicant = 'students'
        # 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:
                self.selenium.get(
                    '%s%s' %
                    (self.live_server_url, reverse('admin:status_summary')))
                self.page_validation(groupType, semester, applicant, appList,
                                     None)
Example #24
0
    def test_access_edit_student_profile_as_user_singup(self):
        self.user_login(self.user)
        # no profile, sign up first
        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()
        ifield = [
            "first_name", "last_name", "student_id", "major", "resume_link",
            "general_question", "additional_skills"
        ]
        for field in ifield:
            self.selenium.find_element_by_name(field).send_keys(
                getattr(student, field))

        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)
        # check via the edit profile button
        self.selenium.find_element_by_xpath(
            "//a[@href='/profile/edit']").click()
        url = self.live_server_url + reverse('edit_student_profile')
        self.assertEqual(self.selenium.current_url, url)

        # update the new info except email email_address

        self.assertTrue(
            self.selenium.find_elements_by_xpath('//h3')[0].text ==
            'Edit Profile')

        new_student = StudentFactory()
        ifield = [
            "first_name", "last_name", "student_id", "major", "resume_link",
            "general_question", "additional_skills"
        ]
        for field in ifield:
            self.selenium.find_element_by_name(field).clear()
            self.selenium.find_element_by_name(field).send_keys(
                getattr(new_student, field))

        bfield = ["college", "year"]
        for j in range(0, len(bfield)):
            Select(self.selenium.find_element_by_name(
                bfield[j])).select_by_value(getattr(new_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, new_student,
                                               skillset)