Ejemplo n.º 1
0
class Main(BasePage):
    '''
    首頁面po
    '''
    _working = _get_working()

    with open(basepage_dir, encoding="utf-8") as f:
        env = yaml.safe_load(f)
        if _working != "port":
            _base_url = env["docker_env"][env["default"]]

    def goto_login(self):
        '''
        進去登錄頁面
        :return:
        '''
        return Login(self._driver)

    def goto_index(self):
        '''
        打開首頁
        :return:
        '''
        return Index(self._driver)

    def back_to_index(self):
        '''
        在其他應用回到首頁
        :return:
        '''
        self.step(main1_dir, "back_to_index")
        return Index(self._driver)

    def goto_exam_plan(self):
        '''
        測試入口,打開考試計劃
        '''
        self.set_implicitly_wait(5)
        self.step(exampage_dir, "goto_exam_plan")
        from page.examPage.exam_planPage.exam_plan import Exam_Plan
        return Exam_Plan(self._driver)

    def goto_room_setting(self):
        '''
        打开考室分配
        '''
        self.step(exampage_dir, "goto_room_setting")
        from page.examPage.room_setting.room_setting import Room_Setting
        return Room_Setting(self._driver)

    def goto_search_of_student(self):
        '''
        打開“按學生查詢”菜單
        '''
        self.step(exampage_dir, "goto_search_of_student")
        return Search_Of_Student(self._driver)
Ejemplo n.º 2
0
class Main(BasePage):
    '''
    首頁面po
    '''
    _working = _get_working()

    with open(basepage_dir, encoding="utf-8") as f:
        env = yaml.safe_load(f)
        if _working != "port":
            _base_url = env["docker_env"][env["default"]]

    def goto_login(self):
        '''
        進去登錄頁面
        '''
        return Login(self._driver)

    def goto_unified_data(self):
        '''
        打開統一數據
        '''
        self.step(main1_dir, "goto_unified_data")
        return Unified_Data(self._driver)

    def close_adduser_pop(self):
        '''
        添加成员成功的确认框,在main提供关闭的入口
        '''
        self.step(main1_dir, "close_adduser_pop")
        return self

    def goto_unified_authorization(self):
        '''
        打开统一授权页面
        '''
        self.step(main1_dir, "goto_unified_authorization")
        return Unified_Authorization(self._driver)

    def close_drawer(self):
        '''
        關閉彈出層
        '''
        try:
            ele = self.step(main1_dir, "close_drawer")
            ele.click()
        except Exception as e:
            pass
Ejemplo n.º 3
0
class Test_Exam_Plan:
    with open(test_edit_room_dir, encoding="utf-8") as f:

        datas = yaml.safe_load(f)
        setup_datas = datas[get_env()]
        test_add_examroom_datas = datas["test_add_examroom"]
        test_delete_examroom_datas = datas["test_delete_examroom"]
        test_edit_examroom_datas = datas["test_edit_examroom"]

    _working = _get_working()
    if _working == "port":

        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()
    else:

        def setup_class(self):
            '''
            非調試端口用
            '''
            self.main = Main().goto_login(). \
                username(self.setup_datas["username"]).password(self.setup_datas["password"]).save(). \
                goto_application(). \
                goto_exam(self.setup_datas["application"])

        def teardown_class(self):
            '''
            非調試端口啓用
            '''
            self.main.close()

    @pytest.mark.parametrize("data", test_add_examroom_datas)
    def test_add_examroom(self, data):
        '''
        验证添加考室
        '''

        result = self.main.goto_room_setting().\
            add_room().edit_roomCode(data["room"]).\
            edit_seatCount(data["seatCount"]).\
            edit_faculty(data["faculty"]).\
            click_save()
        assert result == data["expect"]

    @pytest.mark.parametrize("data", test_delete_examroom_datas)
    def test_delete_examroom(self, data):
        '''
        验证刪除考室
        '''

        result = self.main.goto_room_setting(). \
            search_roomCode(data["room_keys"]).\
            delect_the_first_room().get_current_datacount()
        db = shelve.open("room_total")
        before_room_total = db["room_total"]
        db.close()
        assert result == before_room_total - 1

    @pytest.mark.parametrize("data", test_edit_examroom_datas)
    def test_edit_examroom(self, data):
        '''
        验证編輯考室
        '''

        result = self.main.goto_room_setting(). \
            search_roomCode(data["room_keys"]).\
            edit_the_first_room(). \
            edit_seatCount(data["seatCount"]). \
            edit_startSn_and_endSn(data["startSn"]). \
            click_save()
        assert result == data["expect"]
Ejemplo n.º 4
0
class Test_Bug_All_Of_11_11:
    with open(test_bug_all_of_11_11_dir, encoding="utf-8") as f:
        datas = yaml.safe_load(f)
        setup_datas = datas[get_env()]
        test_check_add_plan_succeed_datas = datas[
            "test_check_add_plan_succeed"]
        test_check_upload_exists_plan_datas = datas[
            "test_check_upload_exists_plan"]

    _working = _get_working()
    if _working == "port":

        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()
    else:

        def setup_class(self):
            '''
            非調試端口用
            '''
            self.main = Main().goto_login(). \
                username(self.setup_datas["username"]).password(self.setup_datas["password"]).save(). \
                goto_application(). \
                goto_exam(self.setup_datas["application"])

        def teardown_class(self):
            '''
            非調試端口啓用
            '''
            self.main.close()

    @pytest.mark.parametrize("data", test_check_add_plan_succeed_datas)
    def test_check_add_plan_succeed(self, data):
        '''
        验证添加計劃成功
        '''

        result = self.main.goto_exam_plan(). \
            add_exists_plan(). \
            plan_name(data["plan_name"]).term(data["term"]). \
            exam_type(data["type"]). \
            upload_exists_plan_import(data["excel_path"]). \
            download_result(). \
            goto_plan_details().del_plan().get_ele_of_addplan()
        assert data["expect"] in result

    @pytest.mark.parametrize("data", test_check_upload_exists_plan_datas)
    def test_check_upload_exists_plan(self, data):
        '''
        验证上传已排计划
        '''

        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(data["plan_name"]).term(data["term"]).\
            upload_exists_plan_import(data["excel_path"]).\
            download_result().\
            check_upload_result()
        assert result == data["expect"]
Ejemplo n.º 5
0
class Test_Student_Of_Makeup_Exam:
    with open(test_student_of_makeup_exam_dir, encoding="utf-8") as f:
        datas = yaml.safe_load(f)
        test_check_upload_exists_plan_datas = datas["test_check_upload_exists_plan"]
        test_check_upload_exists_plan_makeup_datas = datas["test_check_upload_exists_plan_makeup"]
        test_del_exam_plan_datas = datas["test_del_exam_plan"]
        test_check_add_plan_succeed_datas = datas["test_check_add_plan_succeed"]
        test_check_add_plan_fail_datas = datas["test_check_add_plan_fail"]
        test_add_exam1_datas = datas["test_add_exam1"]
        test_add_exam2_datas = datas["test_add_exam2"]
        test_add_exam3_datas = datas["test_add_exam3"]
        test_student_for_del_datas = datas["test_student_for_del"]
        test_student_del_or_T_style_datas = datas["test_student_del_or_T_style"]

    _now_time = datetime.datetime.now()
    _setup_datas = get_env()
    _working = _get_working()
    if _working == "port":
        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()
    else:
        def setup_class(self):
            '''
            非調試端口用
            '''
            self.main = Main().goto_login(). \
                username(self._setup_datas["username"]).password(self._setup_datas["password"]).save(). \
                goto_application(). \
                goto_exam(self._setup_datas["application"])

        def teardown_class(self):
            '''
            非調試端口啓用
            '''
            self.main.close()

    @pytest.mark.parametrize("data", test_check_upload_exists_plan_datas)
    def test_check_upload_exists_plan(self, data):
        '''
        验证上传補考计划
        '''

        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(data["plan_name"]).term(data["term"]).\
            exam_type(data["type"]).\
            upload_exists_plan_import(data["excel_path"]).\
            download_result().\
            check_upload_result()
        assert result == data["expect"]

    @pytest.mark.parametrize("data", test_del_exam_plan_datas)
    def test_del_exam_plan(self,data):
        '''
        驗證刪除考試計劃
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            del_plan().get_ele_of_addplan()
        assert result == data["expect"]

    @pytest.mark.parametrize("data", test_check_add_plan_succeed_datas)
    def test_check_add_plan_succeed(self, data):
        '''
        验证添加計劃成功
        '''
        result = self.main.goto_exam_plan(). \
            add_exists_plan(). \
            plan_name(self._now_time.strftime('%m%d')+data["plan_name"]).term(data["term"]). \
            exam_type(data["type"]). \
            upload_exists_plan_import(data["excel_path"]). \
            download_result(). \
            goto_plan_details(). \
            get_plan_name()
        assert data["expect"] in result

    #補考與其他計劃的衝突,已存在補考計劃11
    @pytest.mark.parametrize("data", test_check_upload_exists_plan_makeup_datas)
    def test_check_upload_exists_plan_makeup(self, data):
        '''
        验证上传考試计划
        '''

        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(data["plan_name"]).term(data["term"]).\
            exam_type(data["type"]).\
            upload_exists_plan_import(data["excel_path"]).\
            download_result().\
            check_upload_result()
        assert result == data["expect"]


    #其他计划添加/编辑考试科目冲突,已存在考試計劃61
    @pytest.mark.parametrize("data", test_add_exam1_datas)
    def test_add_exam1(self, data):
        '''
        验证添加考試科目
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]).add_student_exam(data["num"]). \
            add_examdate(data["examdate"]).add_examtime(data["examtime"]). \
            add_roomCode(data["roomCode"]). \
            click_save().check_add_failed()
        assert data["expect"] in result

    #其他计划添加/编辑考试科目冲突,已存在考試計劃61
    @pytest.mark.parametrize("data", test_add_exam2_datas)
    def test_add_exam2(self, data):
        '''
        验证添加考試科目
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]).add_student_exam(data["num"]).\
            add_examdate(data["examdate"]).add_examtime(data["examtime"]). \
            add_invigilate_one(data["invigilate_one"]).\
            click_save().check_add_failed()
        assert data["expect"] == result

    #其他计划添加/编辑考试科目冲突,已存在考試計劃61
    @pytest.mark.parametrize("data", test_add_exam3_datas)
    def test_add_exam3(self, data):
        '''
        验证添加考試科目
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]).\
            add_examdate(data["examdate"]).add_examtime(data["examtime"]). \
            click_save().check_add_failed()
        assert data["expect"] in result

    @pytest.mark.parametrize("data", test_check_add_plan_fail_datas)
    def test_check_add_plan_fail(self, data):
        '''
        验证模板有問題,導入失敗
        '''

        result = self.main.goto_exam_plan(). \
            add_exists_plan(). \
            plan_name(data["plan_name"]).term(data["term"]). \
            exam_type(data["type"]). \
            upload_exists_plan_import(data["excel_path"]). \
            get_upload_fail_toast()
        assert data["expect"] in result

    @pytest.mark.parametrize("data", test_student_for_del_datas)
    def test_student_for_del(self, data):
        '''
        验证學生移除/T 后無刪除按鈕,樣式變化
        '''
        result = self.main.goto_search_of_student().\
            simple_search_student(data["user_s"]).del_the_fir_student().\
            wait_sleep(1).get_the_fir_username_style().get_the_fir_del_button()
        # 讀取數據庫
        db = shelve.open("username_style")
        username_style = db["username_style"]
        db.close()
        # 驗證無刪除按鈕
        pytest.assume( data["expect"] == result )
        # 驗證樣式變化
        pytest.assume( username_style == "text-decoration: line-through;" )

    @pytest.mark.parametrize("data", test_student_del_or_T_style_datas)
    def test_student_del_or_T_style(self, data):
        '''
        验证從”按學生查詢“移除學生
        '''
        result = self.main.goto_search_of_student().\
            simple_search_student(data["user_s"]).\
            del_the_fir_student().\
            wait_sleep(1).get_the_fir_username_style().\
            get_the_fir_del_button()
        # 讀取數據庫
        db = shelve.open("username_style")
        username_style = db["username_style"]
        db.close()
        # 驗證無刪除按鈕
        pytest.assume( data["expect"] == result )
        # 驗證樣式變化
        pytest.assume( username_style == "text-decoration: line-through;" )
Ejemplo n.º 6
0
class Test_Edit_User_T:
    with open(test_edit_user_t_dir, encoding="utf-8") as f:
        datas = yaml.safe_load(f)
        test_edit_post_user_t_datas = datas["test_edit_post_user_t"]
        test_edit_post_name_user_t_datas = datas["test_edit_post_name_user_t"]
        test_edit_leave_type_user_t_datas = datas["test_edit_leave_type_user_t"]
        test_edit_leave_info_user_t_datas = datas["test_edit_leave_info_user_t"]
        test_edit_password_user_t_datas = datas["test_edit_password_user_t"]
        test_edit_email_t_datas = datas["test_edit_email_t"]
        test_get_email_t_datas = datas["test_get_email_t"]
        test_get_post_t_datas = datas["test_get_post_t"]

    _setup_datas = get_env()
    _working = _get_working()
    if _working == "port":
        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()
        def teardown(self):
            '''
            開啓調試端口啓用
            '''
            try:
                self.main.close_drawer()
            except Exception as e:
                pass
    else:
        def setup_class(self):
            '''
            非調試端口用
            '''
            self.main = Main().goto_login(). \
                username(self._setup_datas["username"]).password(self._setup_datas["password"]).save()


        def teardown(self):
            '''
            關閉抽屜
            :return:
            '''
            try:
                self.main.close_drawer()
            except Exception as e:
                pass

        def teardown_class(self):
            '''
            非調試端口啓用
            '''
            self.main.close()

    @pytest.mark.parametrize("data", test_edit_post_user_t_datas)
    def test_edit_post_user_t(self, data):
        '''
        DC设置岗位,注意uat更改崗位前要等待>=9s,dev等待1s,传参是岗位id
        '''
        result = self.main.goto_unified_data().\
            goto_user().goto_teacher().\
            search_user_t(data["user_t"]).\
            edit_the_first_user_t(data["user_t"]).wait_sleep(9).\
            edit_post(data["post_id"],data["post"]).\
            click_save().get_the_first_user_t_post(data["user_t"])
        assert  data["post"] in result

    @pytest.mark.parametrize("data", test_edit_post_name_user_t_datas)
    def test_edit_post_name_user_t(self, data):
        '''
        DC设置岗位,注意uat更改崗位前要等待>=9s,dev等待1s,传参是岗位名称
        '''
        result = self.main.goto_unified_data().\
            goto_user().goto_teacher().\
            search_user_t(data["user_t"]).\
            edit_the_first_user_t(data["user_t"]).wait_sleep(10).\
            edit_post_name(data["post_name"]).\
            click_save().get_the_first_user_t_post(data["user_t"])
        for post in data["post_name"]:
            assert  post not in result


    @pytest.mark.parametrize("data", test_edit_leave_type_user_t_datas)
    def test_edit_leave_type_user_t(self, data):
        '''
        DC设置休假类型
        '''
        result = self.main.goto_unified_data(). \
            goto_user().goto_teacher(). \
            search_user_t(data["user_t"]). \
            edit_the_first_user_t(data["user_t"]). \
            edit_leave_type(data["leave_type"]).\
            click_save().get_the_first_user_t_post(data["user_t"])
        assert data["expect"] in result


    @pytest.mark.parametrize("data", test_edit_leave_info_user_t_datas)
    def test_edit_leave_info_user_t(self, data):
        '''
        DC设置岗位、入职日期,合同期
        '''
        result = self.main.goto_unified_data(). \
            goto_user().goto_teacher(). \
            search_user_t(data["user_t"]). \
            edit_the_first_user_t(data["user_t"]). \
            edit_post(data["post_id"], data["post"]). \
            edit_date_of_entry(data["entrydate"]).\
            edit_contract_start_date(data["contract_start_date"]).\
            edit_contract_end_date(data["contract_end_date"]).\
            click_save().get_the_first_user_t_post(data["user_t"])
        assert data["expect"] in result


    @pytest.mark.parametrize("data", test_edit_password_user_t_datas)
    def test_edit_password_user_t(self, data):
        '''
        DC修改登錄密碼,uat打開編輯頁面等待元素出現需要>8s
        '''
        result = self.main.goto_unified_data(). \
            goto_user().goto_teacher(). \
            search_user_t(data["user_t"]). \
            edit_the_first_user_t(data["user_t"]). \
            wait_sleep(10).edit_password(self._setup_datas["password"]). \
            click_save().get_the_first_user_t_user(data["user_t"])
        assert data["expect"] == result

    @pytest.mark.parametrize("data", test_edit_email_t_datas)
    def test_edit_email_t(self, data):
        '''
        DC修改系统邮箱
        '''
        result = self.main.goto_unified_data(). \
            goto_user().goto_teacher(). \
            search_user_t(data["user_t"]). \
            edit_the_first_user_t(data["user_t"]). \
            edit_email(data["email"]).\
            click_save().get_the_first_user_t_user(data["user_t"])
        assert data["user_t"] in result

    @pytest.mark.parametrize("data", test_get_email_t_datas)
    def test_get_email_t(self, data):
        '''
        DC获取系统邮箱
        注意:uat打開抽屜定位到元素需要等待5s以上,若在獲取郵箱前等待,則獲取郵箱后無需等待
        '''
        result = self.main.goto_unified_data(). \
            goto_user().goto_teacher(). \
            search_user_t(data["user_t"]). \
            view_the_first_user_t(data["user_t"]). \
            wait_sleep(8).get_email(). \
            close_page().get_the_first_user_t_user(data["user_t"])
        assert data["user_t"] in result


    @pytest.mark.parametrize("data", test_get_post_t_datas)
    def test_get_post_t(self, data):
        '''
        DC獲取人員崗位
        '''
        result = self.main.goto_unified_data(). \
            goto_user().goto_teacher(). \
            search_user_t(data["user_t"]). \
            get_the_first_user_t_post(data["user_t"])
        assert data["expect"] in result
Ejemplo n.º 7
0
class Test_Search_Teacher:

    _do_excel = Do_Excel(username_dir, 'user_t')
    _cases = _do_excel.read_excel()
    _setup_datas = get_env()

    _working = _get_working()
    if _working == "port":

        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()

        def teardown(self):
            '''
            開啓調試端口啓用
            '''
            try:
                self.main.close_drawer()
            except Exception as e:
                pass

    else:

        def setup_class(self):
            '''
            非調試端口用
            '''
            self.main = Main().goto_login(). \
                username(self._setup_datas["username"]).password(self._setup_datas["password"]).save()

        def teardown(self):
            try:
                self.main.close_drawer()
            except Exception as e:
                pass

        def teardown_class(self):
            '''
            非調試端口啓用
            '''
            self.main.close()

    @pytest.mark.parametrize("data", _cases)
    def test_search_teacher_username(self, data):
        '''
        查找老師數量,驗證賬號存在
        '''
        result = self.main.goto_unified_data(). \
            goto_user().goto_teacher(). \
            search_user_t(data.username).\
            get_the_fir_row_text(data.username)

        assert True == result

    @pytest.mark.parametrize("data", _cases)
    def test_get_post_for_search_username(self, data):
        '''
        查找老師賬號,返回老師崗位
        '''
        try:
            result = self.main.goto_unified_data(). \
                goto_user().goto_teacher(). \
                search_user_t(data.username).get_the_first_user_t_post(data.username)
            db = shelve.open("post_t")
            self._do_excel.write_excel(data.id + 1, 3, db["post_t"])
            db.close()
            assert "崗位" in result
        except AssertionError as e:
            self._do_excel.write_excel(data.id + 1, 3, 'None')
            raise e

    @pytest.mark.parametrize("data", _cases)
    def test_get_emali_for_search_username(self, data):
        '''
        查找老師賬號,返回老師崗位
        注意:uat打開抽屜定位到元素需要等待5s以上,若在獲取郵箱前等待,則獲取郵箱后無需等待
        '''
        try:
            result = self.main.goto_unified_data(). \
                goto_user().goto_teacher(). \
                search_user_t(data.username).view_the_first_user_t(data.username).\
                wait_sleep(5).get_email().close_page().get_the_first_user_t_user(data.username)
            db = shelve.open("email_t")
            self._do_excel.write_excel(data.id + 1, 4, db["email_t"])
            db.close()
            assert data.username in result
        except AssertionError as e:
            self._do_excel.write_excel(data.id + 1, 4, 'None')
            raise e
Ejemplo n.º 8
0
class Test_Search_Student:

    _do_excel = Do_Excel(username_dir, 'user_s')
    _cases = _do_excel.read_excel()
    _setup_datas = get_env()


    _working = _get_working()
    if _working == "port":
        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()
        def teardown(self):
            '''
            開啓調試端口啓用
            '''
            try:
                self.main.close_drawer()
            except Exception as e:
                pass


    else:
        def setup_class(self):
            '''
            非調試端口用
            '''
            self.main = Main().goto_login(). \
                username(self._setup_datas["username"]).password(self._setup_datas["password"]).save()

        def teardown(self):
            try:
                self.main.close_drawer()
            except Exception as e:
                pass

        def teardown_class(self):
            '''
            非調試端口啓用
            '''
            self.main.close()

    @pytest.mark.parametrize("data", _cases)
    def test_search_student_username(self, data):
        '''
        查找學生數量,驗證賬號存在
        '''
        result = self.main.goto_unified_data(). \
            goto_user().goto_student(). \
            search_user_s(data.username).\
            get_the_fir_row_text(data.username)

        assert True == result

    @pytest.mark.parametrize("data", _cases)
    def test_get_staffNo_for_search_username(self, data):
        '''
        查找學生賬號,返回學生學號
        '''
        try:
            result = self.main.goto_unified_data(). \
                goto_user().goto_student(). \
                search_user_s(data.username).get_the_first_staffNo(data.username)
            db = shelve.open("staffNo_s")
            self._do_excel.write_excel(data.id + 1, 3,db["staffNo_s"])
            db.close()
            assert True == result
        except AssertionError as e:
            self._do_excel.write_excel(data.id + 1, 3,'None')
            raise e
Ejemplo n.º 9
0
class Test_Story771_661_667:

    _now_time = datetime.datetime.now()
    _num = str(random.randint(0, 100))
    _setup_datas = get_env()
    _working = _get_working()
    if _working == "port":

        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()
    else:

        def setup_class(self):
            '''
            非調試端口用
            '''
            self.main = Main().goto_login(). \
                username(self._setup_datas[0]["username"]).password(self._setup_datas[0]["password"]).save(). \
                goto_application(). \
                goto_exam(self._setup_datas[0]["application"])

        def teardown_class(self):
            '''
            非調試端口啓用
            '''
            self.main.close()

    # 验证上传已排计划
    def check_upload_exists_plan(self, plan_name, term, type, excel_path):
        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+plan_name+self._num).term(term). \
            exam_type(type). \
            upload_exists_plan_import(excel_path).\
            download_result().\
            check_upload_result()
        assert result

    # 验证添加計劃成功
    def check_add_plan_succeed(self, plan_name, term, type, excel_path):
        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+ plan_name+ self._num).term(term). \
            exam_type(type). \
            upload_exists_plan_import(excel_path). \
            download_result().\
            goto_plan_details().\
            get_plan_name()
        assert "當前計劃" in result

    # 驗證刪除考試計劃
    def del_exam_plan(self):
        result = self.main.goto_exam_plan(). \
            goto_the_first_plan_details(). \
            del_plan().get_ele_of_addplan()
        assert result == "添加已排計劃"

    @pytest.mark.parametrize("data", get_data("test_check_upload_exists_plan"))
    def test_check_upload_exists_plan(self, data):
        '''
        验证上传已排计划
        '''

        result = self.check_upload_exists_plan(data["plan_name"], data["term"],
                                               data["type"],
                                               data["excel_path"])
        assert result == data["expect"]

    @pytest.mark.parametrize("data", get_data("test_story667"))
    def test_story667(self, data):
        self.check_add_plan_succeed(data["plan_name"], data["term"],
                                    data["type"], data["excel_path"])

    @pytest.mark.parametrize("data", get_data("test_check_add_plan_succeed"))
    def test_check_add_plan_succeed(self, data):
        '''
        验证添加計劃成功
        '''

        self.check_add_plan_succeed(data["plan_name"], data["term"],
                                    data["type"], data["excel_path"])

    # bug29292-1同科目,不同的班别允许排考编号不同
    @pytest.mark.parametrize("data", get_data("test_bug29292_1"))
    def test_bug29292_1(self, data):
        '''
        验证上传已排计划
        '''
        self.check_add_plan_succeed(data["plan_name"], data["term"],
                                    data["type"], data["excel_path"])
        self.del_exam_plan()

    # bug29292-2同科目,存在相同的班别排考编号不同(考试时间不同)导入报错
    @pytest.mark.parametrize("data", get_data("test_bug29292_2"))
    def test_bug29292_2(self, data):
        '''
        验证上传已排计划
        '''
        result = self.check_upload_exists_plan(data["plan_name"], data["term"],
                                               data["type"],
                                               data["excel_path"])
        assert result == data["expect"]

    # bug29292-3同科目,存在相同的班别排考编号相同(考试时间同)导入成功,且保存成功
    @pytest.mark.parametrize("data", get_data("test_bug29292_3"))
    def test_bug29292_3(self, data):
        '''
        验证上传已排计划
        '''
        self.check_add_plan_succeed(data["plan_name"], data["term"],
                                    data["type"], data["excel_path"])
        self.del_exam_plan()
Ejemplo n.º 10
0
class Test_Mo:
    with open(test_mo_dir, encoding="utf-8") as f:
        datas = yaml.safe_load(f)
        setup_datas = datas[get_env()]
        test_check_upload_exists_plan_datas = datas[
            "test_check_upload_exists_plan"]
        test_check_add_plan_succeed_datas = datas[
            "test_check_add_plan_succeed"]
        test_add_exam_datas = datas["test_add_exam"]
        test_add_exam_stu_num_datas = datas["test_add_exam_stu_num"]
        test_add_examroom_datas = datas["test_add_examroom"]
        test_delete_examroom_datas = datas["test_delete_examroom"]
        test_del_exam_plan_datas = datas["test_del_exam_plan"]

    _working = _get_working()
    if _working == "port":

        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()
    else:

        def setup_class(self):
            '''
            非調試端口用
            '''
            self.main = Main().goto_login(). \
                username(self.setup_datas["username"]).password(self.setup_datas["password"]).save(). \
                goto_application(). \
                goto_exam(self.setup_datas["application"])

        def teardown_class(self):
            '''
            非調試端口啓用
            '''
            self.main.close()

    @pytest.mark.parametrize("data", test_check_upload_exists_plan_datas)
    def test_check_upload_exists_plan(self, data):
        '''
        验证上传已排计划
        '''

        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(data["plan_name"]).term(data["term"]).\
            upload_exists_plan_import(data["excel_path"]).\
            download_result().\
            check_upload_result()
        assert result == data["expect"]

    @pytest.mark.parametrize("data", test_check_add_plan_succeed_datas)
    def test_check_add_plan_succeed(self, data):
        '''
        验证添加計劃成功
        '''

        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(data["plan_name"]).term(data["term"]).\
            upload_exists_plan_import(data["excel_path"]).\
            download_result().\
            goto_plan_details().\
            get_plan_name()
        assert data["expect"] in result

    @pytest.mark.parametrize("data", test_add_exam_datas)
    def test_add_exam(self, data):
        '''
        验证添加考試科目
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]).\
            add_examdate(data["examdate"]).add_examtime(data["examtime"]). \
            add_invigilate_one(data["invigilate_one"]).\
            click_save().close_and_goto_plan_details(). \
            get_current_exam_total()
        assert data["expect"] == result

    @pytest.mark.parametrize("data", test_add_exam_stu_num_datas)
    def test_add_exam_stu_num(self, data):
        '''
        验证添加考試科目
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]).add_student_exam(data["num"]).\
            add_examdate(data["examdate"]).add_examtime(data["examtime"]). \
            click_save().close_and_goto_plan_details(). \
            get_current_exam_total()
        assert data["expect"] == result

    @pytest.mark.parametrize("data", test_delete_examroom_datas)
    def test_delete_examroom(self, data):
        '''
        验证刪除考室
        '''
        result = self.main.goto_room_setting(). \
            search_roomCode(data["room_keys"]).\
            delect_the_first_room().get_current_datacount()
        assert result == data["expect"]

    @pytest.mark.parametrize("data", test_add_examroom_datas)
    def test_add_examroom(self, data):
        '''
        验证添加考室
        '''

        result = self.main.goto_room_setting().\
            add_room().edit_roomCode(data["room"]).\
            edit_seatCount(data["seatCount"]).\
            edit_faculty(data["faculty"]).\
            click_save()
        assert result == data["expect"]

    @pytest.mark.parametrize("data", test_del_exam_plan_datas)
    def test_del_exam_plan(self, data):
        '''
        驗證刪除考試計劃
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            del_plan().get_ele_of_addplan()
        assert result == data["expect"]
Ejemplo n.º 11
0
class Test_Approval:

    with open(test_story638_dir, encoding="utf-8") as f:
        datas = yaml.safe_load(f)
        test_check_upload_exists_plan_datas = datas[
            "test_check_upload_exists_plan"]
        test_check_add_plan_succeed_datas = datas[
            "test_check_add_plan_succeed"]
        test_del_exam_plan_datas = datas["test_del_exam_plan"]
        test_add_exam_same_examCode_datas = datas[
            "test_add_exam_same_examCode"]
        test_add_exam_datas = datas["test_add_exam"]

    # 獲取當前的時間
    _now_time = datetime.datetime.now()
    _setup_datas = get_env()
    _working = _get_working()
    if _working == "port":

        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()

    else:

        def setup(self):
            '''
            非調試端口用
            '''
            self.main = Main()
            # 讀取數據庫
            self.db = shelve.open("overtimeSn")

        def teardown(self):
            '''
            非調試端口啓用
            '''
            self.main.close()
            self.db.close()

    @pytest.mark.parametrize("data", test_check_upload_exists_plan_datas)
    def test_check_upload_exists_plan(self, data):
        '''
        验证上传已排计划
        '''
        result = self.main.goto_exam_plan(). \
            add_exists_plan(). \
            plan_name(self._now_time.strftime('%m%d')+data["plan_name"]).term(data["term"]). \
            exam_type(data["type"]). \
            upload_exists_plan_import(data["excel_path"]). \
            download_result(). \
            check_upload_result()
        assert result == data["expect"]

    @pytest.mark.parametrize("data", test_check_add_plan_succeed_datas)
    def test_check_add_plan_succeed(self, data):
        '''
        验证添加計劃成功
        '''

        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+data["plan_name"]).term(data["term"]).\
            exam_type(data["type"]).\
            upload_exists_plan_import(data["excel_path"]).\
            download_result().\
            goto_plan_details().\
            get_plan_name()
        assert data["expect"] in result

    @pytest.mark.parametrize("data", test_del_exam_plan_datas)
    def test_del_exam_plan(self, data):
        '''
        驗證刪除考試計劃
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            del_plan().get_ele_of_addplan()
        assert result == data["expect"]

    @pytest.mark.parametrize("data", test_add_exam_same_examCode_datas)
    def test_add_exam_same_examCode(self, data):
        # 在驗證創建同排考編號的科目B其日期和時間同步設置

        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]).\
            goto_add_exam().\
            add_examCode(self._now_time+data["examCode"]).add_course_1(data["course_1"]).\
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]).\
            click_save_same_examCode().check_add_succeed()
        assert data["expect"] == result

    @pytest.mark.parametrize("data", test_add_exam_datas)
    def test_add_exam(self, data):
        '''
        验证添加考試科目
        '''
        # add_student_exam(data["num"]).
        # 格式化輸出當前日期+1天的時間
        # examdate = (self._now_time + datetime.timedelta(days=+1)).strftime('%Y-%m-%d')
        examdate = (self._now_time +
                    datetime.timedelta(days=+6)).strftime('%Y-%m-%d')
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]).\
            add_examdate(examdate).add_examtime(data["examtime"]). \
            add_roomCode(data["roomCode"]).add_invigilate_one(data["invigilate_one"]).\
            click_save().check_add_succeed()
        assert data["expect"] == result
Ejemplo n.º 12
0
class Test_Mo_Story771_661_667:

    _now_time = datetime.datetime.now()
    _num = str(random.randint(0,100))
    _setup_datas = get_env()
    _working = _get_working()
    if _working == "port":
        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()
    else:
        def setup_class(self):
            '''
            非調試端口用
            '''
            self.main = Main().goto_login(). \
                username(self._setup_datas[0]["username"]).password(self._setup_datas[0]["password"]).save(). \
                goto_application(). \
                goto_exam(self._setup_datas[0]["application"])

        def teardown_class(self):
            '''
            非調試端口啓用
            '''
            self.main.close()
    # 验证上传已排计划
    def check_upload_exists_plan(self, plan_name,term,type,excel_path):
        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+plan_name+self._num).term(term). \
            exam_type(type). \
            upload_exists_plan_import(excel_path).\
            download_result().\
            check_upload_result()
        assert result

    # 验证添加計劃成功
    def check_add_plan_succeed(self, plan_name,term,type,excel_path):
        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+ plan_name+ self._num).term(term). \
            exam_type(type). \
            upload_exists_plan_import(excel_path). \
            download_result().\
            goto_plan_details().\
            get_plan_name()
        assert "當前計劃" in result

    # 驗證刪除考試計劃
    def del_exam_plan(self):
        result = self.main.goto_exam_plan(). \
            goto_the_first_plan_details(). \
            del_plan().get_ele_of_addplan()
        assert result == "添加已排計劃"

    #添加考試科目
    def add_exam(self, plan_name,examCode,course_1,teacher_1,classdata_1,examdate,examtime,roomCode,invigilate_one):
        result = self.main.goto_exam_plan(). \
            goto_plan_details(plan_name). \
            goto_add_exam(). \
            add_examCode(examCode).add_course_1(course_1). \
            add_teacher_1(teacher_1).add_class_1(classdata_1).\
            add_examdate(examdate).add_examtime(examtime). \
            add_roomCode(roomCode).add_invigilate_one(invigilate_one).\
            click_save().check_add_succeed()
        assert "保存成功" == result

    # 验证刪除考室
    def delete_examroom(self, room_keys):
        result = self.main.goto_room_setting(). \
            search_roomCode(room_keys).\
            delect_the_first_room().get_current_datacount()
        return result

    # 验证添加考室
    def add_examroom(self, room,seatCount,faculty):
        result = self.main.goto_room_setting().\
            add_room().edit_roomCode(room).\
            edit_seatCount(seatCount).\
            edit_faculty(faculty).\
            click_save()
        assert result == "保存成功"

    # 發佈本科計劃-全部
    def release_undergraduate_plan_all(self, plan_name):
        result = self.main.goto_exam_plan(). \
            simple_search_plan(plan_name).\
            goto_release_undergraduate_plan_of_the_fir(plan_name).\
            wait_sleep(1).release_all().\
            click_release().get_ele_of_addplan()
        assert "添加已排計劃" == result

    # 测试前置-添加房间
    @pytest.mark.parametrize("data", get_data("test_add_examroom"))
    def test_add_examroom(self, data):
        '''
        验证添加考室
        '''
        self.add_examroom(data["room"],data["seatCount"],data["faculty"])



    # 测试用例

    @pytest.mark.parametrize("data", get_data("test_check_add_plan_succeed"))
    def test_check_add_plan_succeed(self, data):
        '''
        验证添加計劃成功
        '''
        self.check_add_plan_succeed(data["plan_name"],data["term"],data["type"],data["excel_path"])
        self.release_undergraduate_plan_all(data["plan_name"])
        self.del_exam_plan()



    # bug29292-2同科目,存在相同的班别排考编号不同(考试时间不同)导入报错
    @pytest.mark.parametrize("data", get_data("test_bug29292_2"))
    def test_bug29292_2(self, data):
        '''
        验证上传已排计划
        '''
        result = self.check_upload_exists_plan(data["plan_name"], data["term"], data["type"], data["excel_path"])
        assert result == data["expect"]

    @pytest.mark.parametrize("data", get_data("test_add_exam"))
    def test_add_exam(self, data):
        self.add_exam(data["plan_name"],data["examCode"],data["course_1"],data["teacher_1"],
                      data["classdata_1"],data["examdate"],data["examtime"],data["roomCode"],data["invigilate_one"])


    # 测试后置-删除房间
    @pytest.mark.parametrize("data", get_data("test_delete_examroom"))
    def test_delete_examroom(self, data):
        '''
        验证刪除考室
        '''
        result = self.delete_examroom(data["room_keys"])
        assert result == data["expect"]
Ejemplo n.º 13
0
class Test_Mo_Story786_787_788:

    _now_time = datetime.datetime.now()
    _num = str(random.randint(0,100))
    _setup_datas = get_env()
    _working = _get_working()
    if _working == "port":
        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()
    else:
        def setup_class(self):
            '''
            非調試端口用
            '''
            self.main = Main().goto_login(). \
                username(self._setup_datas[0]["username"]).password(self._setup_datas[0]["password"]).save(). \
                goto_application(). \
                goto_exam(self._setup_datas[0]["application"])

        def teardown_class(self):
            '''
            非調試端口啓用
            '''
            self.main.close()

    # 验证上传已排计划,有错误提示
    def check_upload_error(self, plan_name,term,type,excel_path):
        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+plan_name+self._num).term(term). \
            exam_type(type). \
            upload_exists_plan_import(excel_path).\
            download_result().\
            check_upload_result()
        assert result == True

    # 验证上传已排计划,有警告提示
    def check_upload_warn(self, plan_name,term,type,excel_path):
        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+plan_name+self._num).term(term). \
            exam_type(type). \
            upload_exists_plan_import(excel_path).\
            download_result().\
            check_upload_warn()
        assert result == True

    # 验证添加計劃成功
    def check_add_plan_succeed(self, plan_name,term,type,excel_path):
        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+ plan_name+ self._num).term(term). \
            exam_type(type). \
            upload_exists_plan_import(excel_path). \
            download_result().\
            goto_plan_details().\
            get_plan_name()
        assert "當前計劃" in result

    # 驗證刪除考試計劃
    def del_exam_plan(self):
        result = self.main.goto_exam_plan(). \
            goto_the_first_plan_details(). \
            del_plan().get_ele_of_addplan()
        assert result == "添加已排計劃"


    # 验证刪除考室
    def delete_examroom(self, room_keys):
        result = self.main.goto_room_setting(). \
            search_roomCode(room_keys).\
            delect_the_first_room().get_current_datacount()
        return result

    # 验证添加考室
    def add_examroom(self, room,seatCount,faculty):
        result = self.main.goto_room_setting().\
            add_room().edit_roomCode(room).\
            edit_seatCount(seatCount).\
            edit_faculty(faculty).\
            click_save()
        assert result == "保存成功"

    # 發佈本科計劃-全部
    def release_undergraduate_plan_all(self):
        result = self.main.goto_exam_plan(). \
            goto_release_undergraduate_plan_of_the_fir().\
            wait_sleep(1).release_all().\
            click_release().get_ele_of_addplan()
        assert "添加已排計劃" == result

    # 测试前置-添加房间
    @pytest.mark.parametrize("data", get_data("test_add_examroom"))
    def test_add_examroom(self, data):
        '''
        验证添加考室
        '''
        self.add_examroom(data["room"],data["seatCount"],data["faculty"])



    # 测试用例
    # story788
    @pytest.mark.parametrize("data", get_data("test_check_upload_error_788"))
    def test_check_upload_error_788(self, data):
        '''
        验证上传已排计划,有错误提示
        '''

        self.check_upload_error(data["plan_name"],data["term"],data["type"],data["excel_path"])

    @pytest.mark.parametrize("data", get_data("test_check_upload_warn_788"))
    def test_check_upload_warn_788(self, data):
        '''
        验证上传已排计划,有警告提示
        '''
        self.check_upload_warn(data["plan_name"],data["term"],data["type"],data["excel_path"])

    @pytest.mark.parametrize("data", get_data("test_check_add_plan_succeed"))
    def test_check_add_plan_succeed(self, data):
        '''
        验证添加計劃成功
        '''
        self.check_add_plan_succeed(data["plan_name"],data["term"],data["type"],data["excel_path"])
        self.release_undergraduate_plan_all()
        # self.del_exam_plan()


    # 测试后置-删除房间
    @pytest.mark.parametrize("data", get_data("test_delete_examroom"))
    def test_delete_examroom(self, data):
        '''
        验证刪除考室
        '''
        result = self.delete_examroom(data["room_keys"])
        assert result == data["expect"]
Ejemplo n.º 14
0
class Test_Edit_User_S:
    with open(test_edit_user_s_dir, encoding="utf-8") as f:
        datas = yaml.safe_load(f)
        test_edit_password_user_s_datas = datas["test_edit_password_user_s"]
        test_edit_other_msg_s_datas = datas["test_edit_other_msg_s"]
        test_search_student_username_datas = datas[
            "test_search_student_username"]
        test_edit_post_and_faculy_datas = datas["test_edit_post_and_faculy"]
        test_edit_user_and_staffNo_datas = datas["test_edit_user_and_staffNo"]
        test_edit_user_datas = datas["test_edit_user"]

    _setup_datas = get_env()
    _working = _get_working()
    if _working == "port":

        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()

        def teardown(self):
            '''
            開啓調試端口啓用
            '''
            try:
                self.main.close_drawer()
            except Exception as e:
                pass

    else:

        def setup_class(self):
            '''
            非調試端口用
            '''
            self.main = Main().goto_login(). \
                username(self._setup_datas["username"]).password(self._setup_datas["password"]).save()

        def teardown(self):
            '''
            判斷,若抽屜沒關閉,則先關閉抽屜在進行下一個用例,否則會導致後續用例失敗
            :return:
            '''
            try:
                self.main.close_drawer()
            except Exception as e:
                pass

        def teardown_class(self):
            '''
            非調試端口啓用
            '''
            self.main.close()

    @pytest.mark.parametrize("data", test_edit_password_user_s_datas)
    def test_edit_password_user_s(self, data):
        '''
        DC修改登錄密碼
        '''
        result = self.main.goto_unified_data(). \
            goto_user().goto_student(). \
            search_user_s(data["user_s"]). \
            edit_she_first_user_s(data["user_s"]). \
            edit_password(self._setup_datas["password"]).\
            edit_sortOrder(data["sortorder"]).\
            click_save().get_add_ele()
        assert data["expect"] == result

    @pytest.mark.parametrize("data", test_edit_post_and_faculy_datas)
    def test_edit_post_and_faculy(self, data):
        '''
        DC修改崗位和學院
        '''
        result = self.main.goto_unified_data(). \
            goto_user().goto_student(). \
            search_user_s(data["user_s"]). \
            edit_she_first_user_s(data["user_s"]).edit_post_s(data["post_id"]).\
            edit_faculy(data["faculy_id"]).click_save().get_add_ele()
        assert data["expect"] == result

    @pytest.mark.parametrize("data", test_search_student_username_datas)
    def test_search_student_username(self, data):
        '''
        查找學生數量,驗證賬號存在
        '''
        result = self.main.goto_unified_data(). \
            goto_user().goto_student(). \
            search_user_s(data["user_s"]). \
            get_the_first_staffNo(data["user_s"])
        assert data["user_s"] == result

    @pytest.mark.parametrize("data", test_edit_user_and_staffNo_datas)
    def test_edit_user_and_staffNo(self, data):
        '''
        DC修改賬號和學號
        '''
        result = self.main.goto_unified_data(). \
            goto_user().goto_student(). \
            search_user_s(data["user_s"]). \
            edit_she_first_user_s(data["user_s"]).edit_post_s(data["post_id"]). \
            edit_faculy(data["faculy_id"]).edit_name(data["name"]).edit_enname(data["enname"]). \
            edit_user(data["user"]).edit_password(data["psd"]).edit_sortOrder(data["sortOrder"]). \
            edit_staffNo(data["staffNo"]).edit_type_of_accommodation(). \
            edit_program(data["program"]).edit_programCode(data["programCode"]).\
            edit_entrance_term(data["entrance_term"]).edit_entrance_date(data["entrance_date"]).\
            click_save().get_not_data_text(data["user"])
        return result == data["expect"]

    @pytest.mark.parametrize("data", test_edit_user_datas)
    def test_edit_user(self, data):
        '''
        DC修改
        '''
        result = self.main.goto_unified_data(). \
            goto_user().goto_student(). \
            search_user_s(data["user_s"]). \
            edit_she_first_user_s(data["user_s"]).edit_post_s(data["post_id"]). \
            edit_faculy(data["faculy_id"]).edit_password(data["psd"]).edit_sortOrder(data["sortOrder"]). \
            edit_type_of_accommodation(). \
            edit_program(data["program"]).edit_programCode(data["programCode"]).\
            edit_entrance_term(data["entrance_term"]).edit_entrance_date(data["entrance_date"]).\
            click_save().get_the_first_username(data["user_s"])
        return result == data["expect"]
Ejemplo n.º 15
0
class Test_Bug29693_29682:

    _now_time = datetime.datetime.now()
    _num = str(random.randint(0, 100))
    _setup_datas = get_env()
    _working = _get_working()
    if _working == "port":

        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()
    else:

        def setup_class(self):
            '''
            非調試端口用
            '''
            self.main = Main().goto_login(). \
                username(self._setup_datas[0]["username"]).password(self._setup_datas[0]["password"]).save(). \
                goto_application(). \
                goto_exam(self._setup_datas[0]["application"])

        def teardown_class(self):
            '''
            非調試端口啓用
            '''
            self.main.close()

    # 验证上传已排计划,有错误提示
    def check_upload_error(self, plan_name, term, type, excel_path):
        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+plan_name+self._num).term(term). \
            exam_type(type). \
            upload_exists_plan_import(excel_path).\
            download_result().\
            check_upload_result()
        assert result == True

    # 验证上传已排计划,有警告提示
    def check_upload_warn(self, plan_name, term, type, excel_path):
        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+plan_name+self._num).term(term). \
            exam_type(type). \
            upload_exists_plan_import(excel_path).\
            download_result().\
            check_upload_warn()
        assert result == True

    # 验证添加計劃成功
    def check_add_plan_succeed(self, plan_name, term, type, excel_path):
        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+ plan_name+ self._num).term(term). \
            exam_type(type). \
            upload_exists_plan_import(excel_path). \
            download_result().\
            goto_plan_details().\
            get_plan_name()
        assert "當前計劃" in result

    # 驗證刪除考試計劃
    def del_exam_plan(self):
        result = self.main.goto_exam_plan(). \
            goto_the_first_plan_details(). \
            del_plan().get_ele_of_addplan()
        assert result == "添加已排計劃"

    # 添加考試科目,无考室,验证保存成功
    def add_exam_succeed(self, plan_name, examCode, course_1, teacher_1,
                         classdata_1, examdate, examtime):
        result = self.main.goto_exam_plan(). \
            goto_plan_details(plan_name). \
            goto_add_exam(). \
            add_examCode(examCode).add_course_1(course_1). \
            add_teacher_1(teacher_1).add_class_1(classdata_1). \
            add_examtime(examtime).add_examdate(examdate). \
            click_save().check_add_succeed()
        return result == "保存成功"

    # 添加考試科目,无考室,验证保存失败
    def add_exam_failed(self, plan_name, examCode, course_1, teacher_1,
                        classdata_1, examdate, examtime):
        result = self.main.goto_exam_plan(). \
            goto_plan_details(plan_name). \
            goto_add_exam(). \
            add_examCode(examCode).add_course_1(course_1). \
            add_teacher_1(teacher_1).add_class_1(classdata_1). \
            add_examtime(examtime).add_examdate(examdate). \
            click_save().check_add_failed()
        return result == "保存失敗"

        # 测试用例
        # bug29693

    @pytest.mark.parametrize("data",
                             get_data("test_check_add_plan_succeed_29693"))
    def test_check_add_plan_succeed_29693(self, data):
        '''
        验证添加計劃成功
        '''
        self.check_add_plan_succeed(data["plan_name"], data["term"],
                                    data["type"], data["excel_path"])
        # self.del_exam_plan()

    @pytest.mark.parametrize("data", get_data("test_add_exam_succeed"))
    def test_add_exam_succeed(self, data):
        '''
        验证添加科目成功,存在学生设置
        '''
        self.check_add_plan_succeed(data["plan_name"], data["term"],
                                    data["type"], data["excel_path"])
        plan = self._now_time.strftime('%m%d') + data["plan"]
        self.add_exam_succeed(plan, data["examCode"], data["course_1"],
                              data["teacher_1"], data["classdata_1"],
                              data["examdate"], data["examtime"])
        self.del_exam_plan()

    @pytest.mark.parametrize("data", get_data("test_add_exam_failed"))
    def test_add_exam_failed(self, data):
        '''
        验证添加科目失败,存在学生设置
        '''
        self.check_add_plan_succeed(data["plan_name"], data["term"],
                                    data["type"], data["excel_path"])
Ejemplo n.º 16
0
class Test_Story786_787_788:

    _now_time = datetime.datetime.now()
    _num = str(random.randint(0, 100))
    _setup_datas = get_env()
    _working = _get_working()
    if _working == "port":

        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()
    else:

        def setup_class(self):
            '''
            非調試端口用
            '''
            self.main = Main().goto_login(). \
                username(self._setup_datas[0]["username"]).password(self._setup_datas[0]["password"]).save(). \
                goto_application(). \
                goto_exam(self._setup_datas[0]["application"])

        def teardown_class(self):
            '''
            非調試端口啓用
            '''
            self.main.close()

    # 验证上传已排计划,有错误提示
    def check_upload_error(self, plan_name, term, type, excel_path):
        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+plan_name+self._num).term(term). \
            exam_type(type). \
            upload_exists_plan_import(excel_path).\
            download_result().\
            check_upload_result()
        assert result == True

    # 验证上传已排计划,有警告提示
    def check_upload_warn(self, plan_name, term, type, excel_path):
        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+plan_name+self._num).term(term). \
            exam_type(type). \
            upload_exists_plan_import(excel_path).\
            download_result().\
            check_upload_warn()
        assert result == True

    # 验证添加計劃成功
    def check_add_plan_succeed(self, plan_name, term, type, excel_path):
        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+ plan_name+ self._num).term(term). \
            exam_type(type). \
            upload_exists_plan_import(excel_path). \
            download_result().\
            goto_plan_details().\
            get_plan_name()
        assert "當前計劃" in result

    # 驗證刪除考試計劃
    def del_exam_plan(self):
        result = self.main.goto_exam_plan(). \
            goto_the_first_plan_details(). \
            del_plan().get_ele_of_addplan()
        assert result == "添加已排計劃"

    #添加考試科目,无考室,验证保存失败
    def add_exam(self, plan_name, examCode, course_1, teacher_1, classdata_1,
                 examdate, examtime):
        result = self.main.goto_exam_plan(). \
            goto_plan_details(plan_name). \
            goto_add_exam(). \
            add_examCode(examCode).add_course_1(course_1). \
            add_teacher_1(teacher_1).add_class_1(classdata_1).\
            add_examtime(examtime). add_examdate(examdate).\
            click_save().check_add_failed()
        return result == "保存失敗"

    # 添加考試科目,有考室,验证保存成功
    def add_exam_room(self, plan_name, examCode, course_1, teacher_1,
                      classdata_1, examdate, examtime, roomCode):
        result = self.main.goto_exam_plan(). \
            goto_plan_details(plan_name). \
            goto_add_exam(). \
            add_examCode(examCode).add_roomCode(roomCode).add_course_1(course_1). \
            add_teacher_1(teacher_1).add_class_1(classdata_1).\
            add_examtime(examtime). add_examdate(examdate).\
            click_save().check_add_succeed()
        return result == "保存成功"

    def edit_exam(self, plan_name, roomCode, num):
        '''
        驗證编辑單門科目,编辑课室 ,保存失败
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(plan_name). \
            edit_exam_of_num(num). \
            wait_sleep(2).edit_roomCode(roomCode). \
            click_save().check_add_failed()
        assert "保存失敗" == result

    def add_exam_same_examCode_roomCode(self, plan_name, examCode, course_1,
                                        teacher_1, classdata_1, roomCode):
        '''
        驗證同排考編號科目,考場不可相同
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(plan_name). \
            goto_add_exam(). \
            add_examCode(examCode).add_course_1(course_1). \
            add_teacher_1(teacher_1).add_class_1(classdata_1). \
            add_roomCode_same_examCode(roomCode).\
            click_save_same_examCode().check_add_failed()
        assert result == "保存失敗"

    #学生已刪除/設置為T
    def stu_of_del_or_T(self, user_s):
        result = self.main.goto_search_of_student(). \
            simple_search_student(user_s). \
            get_the_fir_username_style()
        return result

    # 验证添加考室
    def add_examroom(self, room, seatCount, faculty):
        result = self.main.goto_room_setting().\
            add_room().edit_roomCode(room).\
            edit_seatCount(seatCount).\
            edit_faculty(faculty).\
            click_save()
        assert result == "保存成功"

    # 發佈本科計劃-全部
    def release_undergraduate_plan_all(self):
        result = self.main.goto_exam_plan(). \
            goto_release_undergraduate_plan_of_the_fir().\
            wait_sleep(1).release_all().\
            click_release().get_ele_of_addplan()
        assert "添加已排計劃" == result

    # 测试用例
    # story786
    @pytest.mark.parametrize("data", get_data("test_check_upload_warn_786"))
    def test_check_upload_warn_786(self, data):
        '''
        验证上传已排计划,有警告提示
        '''

        self.check_upload_warn(data["plan_name"], data["term"], data["type"],
                               data["excel_path"])

    @pytest.mark.parametrize("data",
                             get_data("test_check_add_plan_succeed_786_1"))
    def test_check_add_plan_succeed_786_1(self, data):
        '''
        验证添加計劃成功
        '''
        self.check_add_plan_succeed(data["plan_name"], data["term"],
                                    data["type"], data["excel_path"])
        self.del_exam_plan()

    @pytest.mark.parametrize("data",
                             get_data("test_check_add_plan_succeed_786_2"))
    def test_check_add_plan_succeed_786_2(self, data):
        '''
        验证添加計劃成功
        '''
        self.check_add_plan_succeed(data["plan_name"], data["term"],
                                    data["type"], data["excel_path"])
        self.del_exam_plan()

    # story787
    # @pytest.mark.skip
    @pytest.mark.parametrize("data", get_data("test_T_787_1"))
    def test_T_787_1(self, data):
        '''发布前撤销设置为T的学生'''
        # self.check_add_plan_succeed(data["plan_name"],data["term"],data["type"],data["excel_path"])
        # ----------------------------设置为T,撤销为T,后发布
        self.release_undergraduate_plan_all()
        assert self.stu_of_del_or_T(data["user_s"]) == False

    # @pytest.mark.skip
    @pytest.mark.parametrize("data", get_data("test_T_787_2"))
    def test_T_787_2(self, data):
        '''发布后撤销设置为T的学生'''
        self.check_add_plan_succeed(data["plan_name"], data["term"],
                                    data["type"], data["excel_path"])
        # ----------------------------设置为T,发布
        # self.release_undergraduate_plan_all()
        # ---------------检查学生为T
        # assert self.stu_of_del_or_T(data["user_s"]) == True
        # self.del_exam_plan()

    # story788

    @pytest.mark.parametrize("data", get_data("test_check_upload_error_788"))
    def test_data(self, data):
        '''
        验证上传已排计划,有错误提示
        '''
        self.check_upload_error(data["plan_name"], data["term"], data["type"],
                                data["excel_path"])

    @pytest.mark.parametrize("data", get_data("test_check_upload_error_788"))
    def test_check_upload_error_788(self, data):
        '''
        验证上传已排计划,有错误提示
        '''

        self.check_upload_error(data["plan_name"], data["term"], data["type"],
                                data["excel_path"])

    #123456
    @pytest.mark.parametrize("data", get_data("test_check_upload_warn_788"))
    def test_check_upload_warn_788(self, data):
        '''
        验证上传已排计划,有警告提示
        '''
        self.check_upload_warn(data["plan_name"], data["term"], data["type"],
                               data["excel_path"])

    @pytest.mark.parametrize("data", get_data("test_add_exam_788"))
    def test_add_exam_788(self, data):
        '''
        验证添加科目成功
        '''
        self.check_add_plan_succeed(data["plan_name"], data["term"],
                                    data["type"], data["excel_path"])
        plan = self._now_time.strftime('%m%d') + data["plan"]
        self.add_exam(plan, data["examCode"], data["course_1"],
                      data["teacher_1"], data["classdata_1"], data["examdate"],
                      data["examtime"])
        self.del_exam_plan()

    @pytest.mark.parametrize("data",
                             get_data("test_check_difnum_the_same_room"))
    def test_check_difnum_the_same_room(self, data):
        '''
        bug29607编辑科目,同一时间不同排考编号的科目考试,占用同一间教室
        '''
        self.check_add_plan_succeed(data["plan_name"], data["term"],
                                    data["type"], data["excel_path"])
        plan = self._now_time.strftime('%m%d') + data["plan"]
        self.add_exam_room(plan, data["examCode"], data["course_1"],
                           data["teacher_1"], data["classdata_1"],
                           data["examdate"], data["examtime"],
                           data["roomCode"])
        self.del_exam_plan()

    @pytest.mark.parametrize("data",
                             get_data("test_add_exam_same_examCode_roomCode"))
    def test_add_exam_same_examCode_roomCode(self, data):
        '''
        bug29607编辑科目,同一时间同排考编号的科目考试,占用同一间教室
        '''
        self.check_add_plan_succeed(data["plan_name"], data["term"],
                                    data["type"], data["excel_path"])
        plan = self._now_time.strftime('%m%d') + data["plan"]
        self.add_exam_same_examCode_roomCode(plan, data["examCode"],
                                             data["course_1"],
                                             data["teacher_1"],
                                             data["classdata_1"],
                                             data["roomCode"])
        self.del_exam_plan()

    @pytest.mark.parametrize("data", get_data("test_upload_and_edit_exam"))
    def test_upload_and_edit_exam(self, data):
        '''
        bug29607编辑科目,同一时间同排考编号的科目考试,占用同一间教室
        '''
        # self.check_add_plan_succeed(data["plan_name"],data["term"],data["type"],data["excel_path"])
        # plan = self._now_time.strftime('%m%d') + data["plan"]
        plan = "0325" + data["plan"]
        self.edit_exam(plan, data["roomCode"], data["num"])
Ejemplo n.º 17
0
class Test_Exam_Plan:

    _now_time = datetime.datetime.now()
    _setup_datas = get_env()
    _working = _get_working()
    if _working == "port":
        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()
    else:
        def setup_class(self):
            '''
            非調試端口用
            '''
            self.main = Main().goto_login(). \
                username(self._setup_datas[0]["username"]).password(self._setup_datas[0]["password"]).save(). \
                goto_application(). \
                goto_exam(self._setup_datas[0]["application"])

        def teardown_class(self):
            '''
            非調試端口啓用
            '''
            self.main.close()

    @pytest.mark.parametrize("data", get_data("test_check_upload_exists_plan"))
    def test_check_upload_exists_plan(self, data):
        '''
        验证上传已排计划
        '''

        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+data["plan_name"]).term(data["term"]).\
            upload_exists_plan_import(data["excel_path"]).\
            download_result().\
            check_upload_result()
        assert result == data["expect"]

    @pytest.mark.parametrize("data", get_data("test_check_add_plan_succeed"))
    def test_check_add_plan_succeed(self, data):
        '''
        验证添加計劃成功
        '''

        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+data["plan_name"]).term(data["term"]). \
            exam_type(data["type"]). \
            upload_exists_plan_import(data["excel_path"]). \
            download_result().\
            goto_plan_details().\
            get_plan_name()
        assert "當前計劃:" in result

    @pytest.mark.parametrize("data", get_data("test_current_exam_total"))
    def test_current_exam_total(self,data):
        '''
        验证当前页考试科目行数
        '''
        result = self.main.goto_exam_plan(). \
            add_exists_plan(). \
            plan_name(data["plan_name"]).term(data["term"]). \
            upload_exists_plan_import(data["excel_path"]).\
            goto_plan_details().\
            get_current_exam_total()
        assert result == data["expect"]

    @pytest.mark.parametrize("data", get_data("test_add_exam_same_examCode_pre1"))
    def test_add_exam_same_examCode_pre1(self,data):
        '''
        验证同排考編號考試時間自動同步,考試未開始
        '''
        # 獲取當前的時間
        now_time = datetime.datetime.now()
        # 格式化輸出當前日期+1天的時間
        examdate = (now_time + datetime.timedelta(days=+1)).strftime('%Y-%m-%d')
        # 先驗證前提條件,創建科目A成功
        result = self.main.goto_exam_plan().\
            goto_plan_details(data["plan_name"]).\
            goto_add_exam().\
            add_examCode(data["examCode"]).add_course_1(data["course_1"]).\
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]).\
            add_examdate(examdate).add_examtime(data["examtime"]).\
            add_roomCode(data["roomCode"]).add_invigilate_one(data["invigilate_one"]).\
            add_grade(data["grade"]).click_save().check_add_succeed()
        assert data["expect"] == result


    @pytest.mark.parametrize("data", get_data("test_add_exam_same_examCode_pre2"))
    def test_add_exam_same_examCode_pre2(self, data):
        # 在驗證創建同排考編號的科目B其日期和時間同步設置
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]).\
            goto_add_exam().\
            add_examCode(data["examCode"]).add_course_1(data["course_1"]).\
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]).\
            click_save_same_examCode().check_add_succeed()
        assert data["expect"] == result

    @pytest.mark.parametrize("data", get_data("test_add_exam_same_examCode_end1"))
    def test_add_exam_same_examCode_end1(self, data):
        '''
        验证添加同排考編號科目,考試已結束提示:
        该排考编号的科目考试已结束,如需继续请更换排考编号
        前提:增加已結束考試科目
        '''
        # 獲取當前的時間
        now_time = datetime.datetime.now()
        # 格式化輸出當前日期-1天的時間
        # examdate = (now_time + datetime.timedelta(days=-1)).strftime('%Y-%m-%d')
        # 先驗證前提條件,創建科目A成功
        result1 = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]). \
            add_examdate(now_time).add_examtime(data["examtime"]). \
            add_grade(data["grade"]).click_save().check_add_succeed()
        assert data["expect"] == result1

    @pytest.mark.parametrize("data", get_data("test_add_exam_same_examCode_end2"))
    def test_add_exam_same_examCode_end2(self, data):
        '''
        验证提示:
        该排考编号的科目考试已结束,如需继续请更换排考编号
        '''
        # 在驗證創建同排考編號的科目B其日期和時間同步設置
        result2 = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]). \
            get_same_examCode_end_toast()
        assert data["expect"] in result2

    @pytest.mark.parametrize("data", get_data("test_add_exam_same_examCode_roomCode"))
    def test_add_exam_same_examCode_roomCode(self,data):
        '''
        驗證同排考編號科目,考場不可相同
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]). \
            add_roomCode_same_examCode(data["roomCode"]).\
            click_save_same_examCode().check_add_failed()
        assert data["expect"] in result

    @pytest.mark.parametrize("data", get_data("test_add_exam_same_examCode_invigilate"))
    def test_add_exam_same_examCode_invigilate(self,data):
        '''
        驗證同排考編號科目,考場不同,監考員不可相同
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]). \
            add_roomCode_same_examCode(data["roomCode"]).add_invigilate_one_same_examCode(data["invigilate_one"]).\
            click_save_same_examCode().check_add_failed()
        assert data["expect"] in result

    @pytest.mark.parametrize("data", get_data("test_add_exam_same_examCode_update_examdate1"))
    def test_add_exam_same_examCode_update_examdate1(self,data):
        '''
        验证同排考編號考試時間更改后自動同步
        前提:創建科目A
        '''
        result= self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]). \
            add_examdate(data["examdate"]).add_examtime(data["examtime"]). \
            add_roomCode(data["roomCode"]).add_invigilate_one(data["invigilate_one"]). \
            add_grade(data["grade"]).click_save().check_add_succeed()
        assert data["expect"] == result

    @pytest.mark.parametrize("data", get_data("test_add_exam_same_examCode_update_examdate2"))
    def test_add_exam_same_examCode_update_examdate2(self, data):
        '''
        验证同排考編號科目B,考試時間更改后自動同步科目A
        '''
        # 獲取當前的時間
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]). \
            add_examdate_same_examCode(data["examdate"]). \
            click_save_same_examCode().\
            close_and_goto_plan_details().\
            get_same_examdate_courses(data["examdate"])
        assert data["expect"] == result

    @pytest.mark.parametrize("data", get_data("test_add_exam"))
    def test_add_exam(self, data):
        '''
        验证添加考試科目
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]).add_student_exam(data["num"]).\
            add_examdate(data["examdate"]).add_examtime(data["examtime"]). \
            add_roomCode(data["roomCode"]).add_invigilate_one(data["invigilate_one"]).\
            click_save().check_add_succeed()
        assert data["expect"] == result

    @pytest.mark.parametrize("data", get_data("test_add_double_exam"))
    def test_add_double_exam(self,data):
        '''
        一次添加兩門科目
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]). \
            add_course_2(data["course_2"]).add_teacher_2(data["teacher_2"]).add_class_2(data["classdata_2"]). \
            add_student_exam(data["num"]).add_examdate(data["examdate"]).add_examtime(data["examtime"]). \
            add_roomCode(data["roomCode"]).add_invigilate_one(data["invigilate_one"]).\
            click_save().check_add_succeed()
        assert data["expect"] == result


    @pytest.mark.parametrize("data", get_data("test_del_exam_plan"))
    def test_del_exam_plan(self,data):
        '''
        驗證刪除考試計劃
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            del_plan().get_ele_of_addplan()
        assert result == data["expect"]

    @pytest.mark.parametrize("data", get_data("test_del_exam"))
    def test_del_exam(self,data):
        '''
        驗證刪除考試
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            del_exam(data["num"]).get_current_exam_total()
        db = shelve.open("exam_total")
        before_exam_total = db["exam_total"]
        db.close()
        assert result == int(before_exam_total) - 1

    @pytest.mark.parametrize("data", get_data("test_add_exam_type"))
    def test_add_exam_type(self, data):
        '''
        驗證添加單門科目,考試形式為:閉卷,工具全部
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]).\
            add_exam_ruletype_close_book_1().add_exam_ruletype_book_1().\
            add_exam_ruletype_calcu_1().add_exam_ruletype_dict_1().add_exam_ruletype_computer_1().\
            add_examdate(data["examdate"]).add_examtime(data["examtime"]). \
            click_save().check_add_succeed()
        assert data["expect"] == result

    @pytest.mark.parametrize("data", get_data("test_edit_exam_room"))
    def test_edit_exam_room(self, data):
        '''
        驗證编辑單門科目,编辑课室
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            edit_exam_of_num(data["num"]). \
            wait_sleep(1).\
            edit_roomCode(data["roomCode"]). \
            click_save().check_edit_succeed()
        assert "保存成功" == result

    @pytest.mark.parametrize("data", get_data("test_edit_exam_date"))
    def test_edit_exam_date(self, data):
        '''
        驗證编辑單門科目,编辑考试时间
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            edit_exam_of_num(data["num"]). \
            wait_sleep(1). \
            edit_examdate(data["examdate"]). \
            edit_examtime(data["examtime"]).\
            click_save().check_edit_succeed()
        assert "保存成功" == result

    @pytest.mark.parametrize("data", get_data("test_edit_exam_invigilate_one"))
    def test_edit_exam_invigilate_one(self, data):
        '''
        驗證编辑單門科目,编辑考试时间
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            wait_sleep(1).get_invigilate(data["num"]).\
            edit_exam_of_num(data["num"]). \
            wait_sleep(1). \
            edit_invigilate_one(data["invigilate_one"]). \
            click_save().check_edit_succeed()
        assert "保存成功" == result

    @pytest.mark.parametrize("data", get_data("test_add_double_exam_type"))
    def test_add_double_exam_type(self, data):
        '''
        驗證添加雙門科目,科目一、二考試形式為:閉卷,工具全部
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]). \
            add_exam_ruletype_close_book_1().add_exam_ruletype_book_1(). \
            add_exam_ruletype_calcu_1().add_exam_ruletype_dict_1().add_exam_ruletype_computer_1(). \
            add_course_2(data["course_2"]).add_teacher_2(data["teacher_2"]).add_class_2(data["classdata_2"]). \
            add_exam_ruletype_close_book_2().add_exam_ruletype_book_2(). \
            add_exam_ruletype_calcu_2().add_exam_ruletype_dict_2().add_exam_ruletype_computer_2(). \
            add_examdate(data["examdate"]).add_examtime(data["examtime"]). \
            add_roomCode(data["roomCode"]).add_invigilate_one(data["invigilate_one"]). \
            click_save().check_add_succeed()
        assert data["expect"] == result

    @pytest.mark.parametrize("data", get_data("test_release_undergraduate_plan_for_date"))
    def test_release_undergraduate_plan_for_date(self, data):
        '''
        驗證根據考試日期發佈本科計劃
        '''
        result = self.main.goto_exam_plan(). \
            simple_search_plan(data["plan_name"]).\
            goto_release_undergraduate_plan_of_the_fir(data["plan_name"]).\
            wait_sleep(1).release_for_date(data["date_list"]).\
            teacher_view_date(data["date_t"]).student_view_date(data["date_t"]).\
            click_release().get_ele_of_addplan()
        assert data["expect"] == result

    @pytest.mark.parametrize("data", get_data("test_release_undergraduate_plan_all"))
    def test_release_undergraduate_plan_all(self, data):
        '''
        驗證發佈本科計劃-全部
        '''
        result = self.main.goto_exam_plan(). \
            simple_search_plan(data["plan_name"]).\
            goto_release_undergraduate_plan_of_the_fir(data["plan_name"]).\
            wait_sleep(1).release_all().\
            teacher_view_date(data["date_t"]).student_view_date(data["date_t"]).\
            click_release().get_ele_of_addplan()
        assert data["expect"] == result

    @pytest.mark.parametrize("data", get_data("test_release_undergraduate_plan_all"))
    def test_release_undergraduate_plan_all(self, data):
        '''
        驗證發佈本科計劃-全部
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]).add_student_exam(data["num"]).\
            add_examdate(data["examdate"]).add_examtime(data["examtime"]). \
            add_roomCode(data["roomCode"]).add_invigilate_one(data["invigilate_one"]).\
            click_save().check_add_succeed()
        assert data["expect"] == result
Ejemplo n.º 18
0
class Test_bug27204:
    with open(test_bug27204_dir, encoding="utf-8") as f:
        datas = yaml.safe_load(f)
        setup_datas = datas[get_env()]
        test_check_add_plan_succeed_datas = datas[
            "test_check_add_plan_succeed"]
        test_add_double_exam_datas = datas["test_add_double_exam"]

    _working = _get_working()
    if _working == "port":

        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()
    else:

        def setup_class(self):
            '''
            非調試端口用
            '''
            self.main = Main().goto_login(). \
                username(self.setup_datas["username"]).password(self.setup_datas["password"]).save(). \
                goto_application(). \
                goto_exam(self.setup_datas["application"])

        def teardown_class(self):
            '''
            非調試端口啓用
            '''
            self.main.close()

    @pytest.mark.parametrize("data", test_check_add_plan_succeed_datas)
    def test_check_add_plan_succeed(self, data):
        '''
        验证添加計劃成功
        '''

        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(data["plan_name"]).term(data["term"]).\
            upload_exists_plan_import(data["excel_path"]).\
            download_result().\
            goto_plan_details().\
            get_plan_name()
        assert data["expect"] in result

    @pytest.mark.parametrize("data", test_add_double_exam_datas)
    def test_add_double_exam(self, data):
        '''
        一次添加兩門科目
        '''
        result = self.main.goto_exam_plan(). \
            goto_plan_details(data["plan_name"]). \
            goto_add_exam(). \
            add_examCode(data["examCode"]).add_course_1(data["course_1"]). \
            add_teacher_1(data["teacher_1"]).add_class_1(data["classdata_1"]). \
            add_course_2(data["course_2"]).add_teacher_2(data["teacher_2"]).add_class_2(data["classdata_2"]). \
            add_student_exam(data["num"]).add_examdate(data["examdate"]).add_examtime(data["examtime"]). \
            add_roomCode(data["roomCode"]).add_invigilate_one(data["invigilate_one"]).\
            click_save(). \
            close_and_goto_plan_details(). \
            get_current_exam_total()
        assert data["expect"] == result
Ejemplo n.º 19
0
class Test_Mo_610_608_638:
    with open(test_mo_610_608_638_dir, encoding="utf-8") as f:
        datas = yaml.safe_load(f)
        test_add_examroom_datas = datas["test_add_examroom"]
        test_delete_examroom_datas = datas["test_delete_examroom"]
        test_check_upload_exists_plan_datas = datas["test_check_upload_exists_plan"]
        test_check_add_plan_succeed_datas = datas["test_check_add_plan_succeed"]
        test_student_del_or_T_style_datas = datas["test_student_del_or_T_style"]

    # 獲取當前的時間
    _now_time = datetime.datetime.now()
    _setup_datas = get_env()
    _working = _get_working()
    if _working == "port":
        def setup(self):
            '''
            開啓調試端口啓用
            '''
            self.main = Main()
    else:
        def setup_class(self):
            '''
            非調試端口用
            '''
            self.main = Main().goto_login(). \
                username(self._setup_datas["username"]).password(self._setup_datas["password"]).save(). \
                goto_application(). \
                goto_exam(self._setup_datas["application"])

        def teardown_class(self):
            '''
            非調試端口啓用
            '''
            self.main.close()

    # 前置條件準備------》

    @pytest.mark.parametrize("data", test_add_examroom_datas)
    def test_add_examroom(self, data):
        '''
        验证添加考室
        '''

        result = self.main.goto_room_setting().\
            add_room().edit_roomCode(data["room"]).\
            edit_seatCount(data["seatCount"]).\
            edit_faculty(data["faculty"]).\
            click_save()
        assert result == data["expect"]

    # 後置條件清楚數據------》

    @pytest.mark.parametrize("data", test_delete_examroom_datas)
    def test_delete_examroom(self, data):
        '''
        验证刪除考室
        '''

        result = self.main.goto_room_setting(). \
            search_roomCode(data["room_keys"]).\
            delect_the_first_room().get_current_datacount()
        db = shelve.open("room_total")
        before_room_total = db["room_total"]
        db.close()
        assert result == before_room_total - 1

    # 測試用例部分------》
    @pytest.mark.parametrize("data", test_check_upload_exists_plan_datas)
    def test_check_upload_exists_plan(self, data):
        '''
        验证上传已排计划
        '''

        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+data["plan_name"]).term(data["term"]). \
            exam_type(data["type"]). \
            upload_exists_plan_import(data["excel_path"]).\
            download_result().\
            check_upload_result()
        assert result == data["expect"]

    @pytest.mark.parametrize("data", test_check_add_plan_succeed_datas)
    def test_check_add_plan_succeed(self, data):
        '''
        验证添加計劃成功
        '''

        result = self.main.goto_exam_plan().\
            add_exists_plan().\
            plan_name(self._now_time.strftime('%m%d')+data["plan_name"]).term(data["term"]). \
            exam_type(data["type"]). \
            upload_exists_plan_import(data["excel_path"]).\
            download_result().\
            goto_plan_details().\
            get_plan_name()
        assert data["expect"] in result

    @pytest.mark.parametrize("data", test_student_del_or_T_style_datas)
    def test_student_del_or_T_style(self, data):
        '''
        验证從”按學生查詢“移除學生
        '''
        result = self.main.goto_search_of_student().\
            simple_search_student(data["user_s"]).\
            del_the_fir_student().\
            get_the_fir_username_style().get_the_fir_del_button
        # 讀取數據庫
        db = shelve.open("username_style")
        username_style = db["username_style"]
        db.close()
        # 驗證無刪除按鈕
        pytest.assume( data["expect"] == result )
        # 驗證樣式變化
        pytest.assume( username_style == "text-decoration: line-through;" )