def test_03(self):
     """多文件"""
     self.step_log_path = self.case_log_path
     filename = Data().test_field_file_name
     output = Data().test_field_output
     self.login(**self.teacher_data)
     self.click_and_jump(1, *ElementSelector.test_field_btn_loc)
     self.multiple_files_test_field(filename, '多文件测试', output)
Beispiel #2
0
class TestErrorCheck(BaseTestCase):
    file_name, name = __file__, __name__
    case_log_path = log_path(file_name, name)

    student_data = Data().student_data()

    @log_decorator(case_log_path)
    def test_field_error(self):
        """
        试炼场
        :return:
        """
        self.step_log_path = self.case_log_path
        self.login(**self.student_data)
        self.click_and_jump(1, *ElementSelector.test_field_btn_loc)
        self.check_error()

    @log_decorator(case_log_path)
    def test_course_field_error(self):
        """
        课件查看页面精简试炼场
        :return:
        """
        self.step_log_path = self.case_log_path
        self.login(**self.student_data)
        self.click_button(*ElementSelector.bar_course_loc)
        self.click_and_jump(
            1,
            *ElementSelector.course_list_card_mode_first_course_loc,
            loading=True)
        self.click_button(
            *ElementSelector.course_detail_start_study_course_loc,
            loading=True)
        code = wrong_code()
        self.course_field_operation(code, 'Error', wrong=True)
 def test_04(self):
     """打开草稿"""
     self.step_log_path = self.case_log_path
     output = Data().test_field_output
     self.login(**self.teacher_data)
     self.click_and_jump(1, *ElementSelector.test_field_btn_loc)
     self.open_file(output)
Beispiel #4
0
class TestPackageCourse(BaseTestCase):
    file_name = __file__
    name = __name__

    d = Data()
    teacher_data = d.teacher_data()
    student_data = d.student_data()

    def test_package_course_01(self):
        self.step_log_path = get_log_path(self.file_name, self.name)
        self.login(**self.teacher_data, teacher_assert=True)
        self.click_button(*ElementSelector.standard_course_btn_loc)
        self.add_course_loop()
        self.add_course_wrong()
        self.click_button(*ElementSelector.standard_course_btn_loc)
        self.date_selection('课件', '自动上传课件')
        self.search_input('自动上传课件')
        self.get_new_driver()
        self.login(**self.student_data, student_assert=True)
        self.click_button(*ElementSelector.standard_course_btn_loc)
        self.student_check_course_loop()
        self.date_selection('课件', '自动上传课件', student=True)
        self.search_input('自动上传课件')

    def test_package_course_02(self):
        self.step_log_path = get_log_path(self.file_name, self.name)
        self.login(**self.teacher_data, teacher_assert=True)
        self.click_button(*ElementSelector.checkpoint_course_loc)
        self.click_button(*ElementSelector.index_course_btn_loc, loading=True)
        self.subject_add_course_loop()
        self.get_new_driver()
        self.login(**self.student_data, student_assert=True)
        self.click_button(*ElementSelector.checkpoint_course_loc)
        self.click_button(*ElementSelector.index_course_btn_loc, loading=True)
        self.subject_student_check_course_loop()
Beispiel #5
0
class DoHomeworkSimple(BaseTestCase):
    file_name = __file__
    name = __name__
    case_log_path = log_path(file_name, name)

    student_data = Data().student_data()
    username = Data().student_username_for_edu()
    password = Data().password_for_edu
    student_name = Data().student_name_for_edu()

    @log_decorator(case_log_path)
    def test_01(self):
        self.step_log_path = self.case_log_path
        self.login(**self.student_data)
        self.click_button(*ElementSelector.bar_homework_loc, loading=True)
        self.student_do_homework_simple(homework_name=None)
Beispiel #6
0
 def test_login_01(self):
     """
     登录接口
     :return:
     """
     headers = {
         'Content-Type':
         "application/json",
         "User-Agent":
         "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
         "Chrome/73.0.3683.86 Safari/537.36"
     }
     url = f'{self.ip}/user/login'
     username = Data().teacher_data()['username']
     password = Data().teacher_data()['password']
     data = {"password": password, "username": username}
     response = requests.post(url=url, json=data, headers=headers)
     assert_res(response.text)
 def test_06(self):
     """
     试炼场发布作品
     :return:
     """
     work_name = Data().work_name
     self.step_log_path = self.case_log_path
     self.login(**self.student_data)
     self.click_and_jump(1, *ElementSelector.test_field_btn_loc)
     self.submit_work(work_name)
Beispiel #8
0
class TestWishBox(BaseTestCase):
    file_name = __file__
    name = __name__
    case_log_path = log_path(file_name, name)

    student_data = Data().student_data()

    @log_decorator(case_log_path)
    def test_wish_box(self):
        self.step_log_path = self.case_log_path
        self.login(**self.student_data)
        self.wish_box()
Beispiel #9
0
class AddResourcesCase(BaseTestCase):
    file_name = __file__
    name = __name__

    url = Data().ip_for_edu()
    teacher_data = Data().teacher_data()
    username_teacher = Data().teacher_username_for_edu()
    teacher_name = Data().teacher_name_for_edu()
    password = Data().password_for_edu

    def test_add_resources(self):
        self.step_log_path = get_log_path(self.file_name, self.name)
        self.login(**self.teacher_data, teacher_assert=True)
        self.click_button(*ElementSelector.teach_management_btn_loc)
        self.click_button(*ElementSelector.resource_manage_tab_loc,
                          loading=True)
        self.click_button(*ElementSelector.resource_type_sel_loc,
                          loading=False,
                          wait=True)
        self.click_button(*ElementSelector.school_resource_btn_loc, wait=True)
        self.add_resources()
Beispiel #10
0
 def __init__(self, identity=''):
     self.ip = Data().api_ip_for_edu()
     self.headers = {
         'Content-Type':
         'application/json',
         'User-Agent':
         'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
         'Chrome/68.0.3440.84 Safari/537.36'
     }
     self.identity = identity
     if not self.identity:
         raise Exception(
             '身份不能为空,请输入 identity="manager"、"teacher"或"student"')
     elif 'manager' == self.identity:
         manager_data = Data().manager_data()
         self.username = manager_data['username']
         self.password = manager_data['password']
     elif 'teacher' == self.identity:
         teacher_data = Data().teacher_data()
         self.username = teacher_data['username']
         self.password = teacher_data['password']
     elif 'student' == self.identity:
         student_data = Data().student_data()
         self.username = student_data['username']
         self.password = student_data['password']
     else:
         raise Exception('错误的身份,请输入 identity="manager"、"teacher"或"student"')
     url = f'{self.ip}/pc/login'
     data = {"password": self.password, "username": self.username}
     t = requests.session()
     login_ret = t.post(url=url, headers=self.headers, json=data)
     data_ret = login_ret.json()
     try:
         token = data_ret['data']['token']
     except TypeError:
         print(f'接口/pc/login报错,返回{data_ret["msg"]}')
     except KeyError:
         print(login_ret)
     else:
         self.headers['token'] = token
Beispiel #11
0
class TestAIExperience(BaseTestCase):
    file_name = __file__
    name = __name__
    case_log_path = log_path(file_name, name)

    teacher_data = Data().teacher_data()

    @log_decorator(case_log_path)
    def test_01(self):
        self.step_log_path = self.case_log_path
        self.login(**self.teacher_data)
        self.click_button(*ElementSelector.ai_experience_loc)
        self.ai_experience()
Beispiel #12
0
class TestHomework(BaseTestCase):
    file_name = __file__
    name = __name__
    case_log_path = log_path(file_name, name)

    d = Data()
    teacher_data = d.teacher_data()
    student_data = d.student_data()
    username = Data().teacher_username_for_edu()
    password = Data().password_for_edu
    username_student = Data().student_username_for_edu()
    student_name = Data().student_name_for_edu()
    teacher_name = Data().teacher_name_for_edu()

    @log_decorator(case_log_path)
    def test_01_homework_loop(self):
        self.step_log_path = self.case_log_path
        # 教师操作
        self.login(**self.teacher_data)
        self.click_button(*ElementSelector.bar_homework_loc)
        self.add_homework_loop()
        # self.date_selection('作业', Data().homework_name)   # 日期筛选全部砍掉了,先保留代码免得后面又加回来
        # 学生操作
        self.get_new_driver()
        self.login(**self.student_data)
        self.click_button(*ElementSelector.bar_homework_loc)
        self.student_do_homework_loop()
        # self.date_selection('作业', Data().homework_name, student=True)

    @log_decorator(case_log_path)
    def test_02_add_homework_wrong(self):
        self.step_log_path = self.case_log_path
        self.login(**self.teacher_data)
        self.click_button(*ElementSelector.bar_homework_loc)
        self.add_homework_wrong()

    @log_decorator(case_log_path)
    def test_03_homework_search(self):
        self.step_log_path = self.case_log_path
        # 教师操作
        self.login(**self.teacher_data)
        self.click_button(*ElementSelector.bar_homework_loc)
        self.search_input('自动')
        # 学生操作
        self.get_new_driver()
        self.login(**self.student_data)
        self.click_button(*ElementSelector.bar_homework_loc)
        self.search_input('自动')
Beispiel #13
0
class TestCourse(BaseTestCase):
    file_name, name = __file__, __name__
    case_log_path = log_path(file_name, name)
    d = Data()
    manager_data = d.manager_data()
    teacher_data = d.teacher_data()
    student_data = d.student_data()

    @log_decorator(case_log_path)
    def test_01_teacher_preview_course(self):
        self.step_log_path = self.case_log_path
        self.login(**self.teacher_data)
        self.click_button(*ElementSelector.bar_course_loc)
        self.preview_course()

    @log_decorator(case_log_path)
    def test_02_traverse_check_course(self):
        self.step_log_path = self.case_log_path
        self.login(**self.teacher_data)
        self.click_button(*ElementSelector.bar_course_loc)
        course_name = self.add_course_simple(self.teaching_package_list[0])
        self.click_and_jump(
            1, *ElementSelector.course_list_card_mode_first_course_loc)
        self.check_course_simple(course_name, teacher=True, check_all=True)
        self.switch_window(0)
        self.del_course()

    @log_decorator(case_log_path)
    def test_03_student_do_practice(self):
        self.step_log_path = self.case_log_path
        self.login(**self.student_data)
        self.click_button(*ElementSelector.bar_course_loc)
        self.click_and_jump(
            1,
            *ElementSelector.course_list_card_mode_first_course_loc,
            loading=True)
        self.student_do_practice()
class TestFieldCase(BaseTestCase):
    file_name = __file__
    name = __name__
    case_log_path = log_path(file_name, name)

    d = Data()
    teacher_data = d.teacher_data()
    student_data = d.student_data()

    @log_decorator(case_log_path)
    def test_01(self):
        """turtle"""
        self.step_log_path = self.case_log_path

        self.login(**self.student_data)
        self.click_and_jump(1, *ElementSelector.test_field_btn_loc)
        self.do_test_field('turtle')

    @log_decorator(case_log_path)
    def test_02(self):
        """pygame"""
        self.step_log_path = self.case_log_path
        self.login(**self.student_data)
        self.click_and_jump(1, *ElementSelector.test_field_btn_loc)
        self.do_test_field('pygame')

    @log_decorator(case_log_path)
    def test_03(self):
        """多文件"""
        self.step_log_path = self.case_log_path
        filename = Data().test_field_file_name
        output = Data().test_field_output
        self.login(**self.teacher_data)
        self.click_and_jump(1, *ElementSelector.test_field_btn_loc)
        self.multiple_files_test_field(filename, '多文件测试', output)

    @log_decorator(case_log_path)
    def test_04(self):
        """打开草稿"""
        self.step_log_path = self.case_log_path
        output = Data().test_field_output
        self.login(**self.teacher_data)
        self.click_and_jump(1, *ElementSelector.test_field_btn_loc)
        self.open_file(output)

    @log_decorator(case_log_path)
    def test_05(self):
        """3D打印"""
        self.step_log_path = self.case_log_path
        self.login(**self.teacher_data)
        self.click_and_jump(1, *ElementSelector.test_field_btn_loc)
        self.three_dimensional()

    @log_decorator(case_log_path)
    def test_06(self):
        """
        试炼场发布作品
        :return:
        """
        work_name = Data().work_name
        self.step_log_path = self.case_log_path
        self.login(**self.student_data)
        self.click_and_jump(1, *ElementSelector.test_field_btn_loc)
        self.submit_work(work_name)

    @log_decorator(case_log_path)
    def test_07(self):
        """素材库"""
        self.step_log_path = self.case_log_path
        self.login(**self.student_data)
        self.click_and_jump(1, *ElementSelector.test_field_btn_loc)
        self.upload_material()
Beispiel #15
0
class TestMainProcess(BaseTestCase):
    file_name, name = __file__, __name__
    case_log_path = log_path(file_name, name)
    d = Data()
    manager_data = d.manager_data()
    teacher_data = d.teacher_data()
    student_data = d.student_data()

    homework_name = d.homework_name
    admin_class_name = d.admin_class_name_for_edu()
    pro_class_name = d.pro_class_name_for_edu()

    @log_decorator(case_log_path)
    def test_01_main_process_course(self):
        self.step_log_path = self.case_log_path
        # 教师操作
        self.login(**self.teacher_data)
        self.click_button(*ElementSelector.bar_course_loc)
        course_name = self.add_course_simple(self.teaching_package_list[0])
        self.click_and_jump(
            1, *ElementSelector.course_list_card_mode_first_course_loc)
        self.check_course_simple(course_name, teacher=True)
        self.teacher_check_index_course(course_name)
        # 学生操作
        self.get_new_driver()
        self.login(**self.student_data)
        self.student_check_index_course(course_name)
        self.click_and_jump(
            1, *ElementSelector.course_list_card_mode_first_course_name_loc)
        self.check_course_simple(course_name)

    @log_decorator(case_log_path)
    def test_02_main_process_homework(self):
        self.step_log_path = self.case_log_path
        # 教师发布作业
        self.login(**self.teacher_data)
        self.click_button(*ElementSelector.bar_homework_loc)
        self.click_button(*ElementSelector.homework_list_add_homework_btn_loc,
                          loading=True)
        add_homework_param = {
            'homework_name': self.homework_name,
            'answer_config': self.answer_list[0],
            'difficulty': 1
        }
        self.add_homework_simple(**add_homework_param)
        self.teacher_check_index_homework(self.homework_name)
        # 学生做作业
        self.get_new_driver()
        self.login(**self.student_data)
        self.student_check_index_homework(self.homework_name)
        self.click_button(*ElementSelector.bar_homework_loc, loading=True)
        completion, correct = self.student_do_homework_simple(
            self.homework_name)
        # 教师检查作业详情
        self.switch_to_default_driver()
        self.teacher_check_index_homework(self.homework_name)
        self.teacher_check_homework_simple(self.homework_name, completion,
                                           correct)

    @log_decorator(case_log_path)
    def test_03_delete_course(self):
        self.step_log_path = self.case_log_path
        self.login(**self.teacher_data)
        self.click_button(*ElementSelector.bar_course_loc)
        self.del_course()