class TestCustomerInput: def setup(self): self.main = Main() @pytest.mark.parametrize('customername, contactPhone', customer_name) def test_customer_input(self, customername, contactPhone): self.main.customer_input().add_customer(customername, contactPhone) def teardown(self): self.main.close()
class Test0924: with open(test_authorization_dir, encoding="utf-8") as f: datas = yaml.safe_load(f) setup_datas = datas["setup_datas"] test_get_memu_num_datas = datas["test_get_memu_num"] 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"]) self.main = Main() def setup(self): ''' 非調試端口用 ''' self.begin=self.main.goto_login(). \ username(self.setup_datas["username"]).password(self.setup_datas["password"]).save(). \ goto_application(). \ goto_exam(self.setup_datas["application"]) def teardown(self): ''' 非調試端口用 ''' self.main.back_to_index().quit() def teardown_class(self): ''' 非調試端口啓用 ''' self.main.close() # def setup(self): # ''' # 開啓調試端口啓用 # ''' # self.main = Main() @pytest.mark.parametrize("data", test_get_memu_num_datas) def test_get_memu_num(self, data): ''' 權限測試,驗證取消排考計劃權限,菜單只有5個 ''' result = self.begin.get_memu_num() assert result == data["expect"]
class TestMain(): def setup(self): self.main = Main(reuse=True) @pytest.mark.parametrize("username, mobile", [('test', '15515155166')]) def test_add_member(self, username, mobile): t = str(int(time.time())) username += t contactPage = self.main.goto_add_member() contactPage.add_member(username, t, mobile) titles = contactPage.get_titles_in_list(username) assert username in titles def teardown(self): self.main.close()
class TestLogin: _name = "test11" _psd = "123456" def setup_class(self): self.main = Main() def teardown_class(self): self.main.close() def setup(self): self.login = self.main.goto_login().username(self._name).password(self._psd).save() def teardown(self): self.main.quit() @pytest.mark.parametrize("name,psd",[("test12","wemust123"),("test11","123456")]) @pytest.mark.skip def testlogin(self,name,psd): ''' 測試登錄功能 :return: ''' self.main.goto_login().username(name).password(psd).save() def test_selectapplication(self): ''' 測試打開選擇應用的頁面 :return: ''' self.login.goto_application() def test_gotoapplication(self): ''' 測試打開某個應用 :return: ''' application_name = "課表" memu = "教師課表(本科)" self.login.goto_application().\ goto_classtimetable(application_name). \ goto_teacher_management_degree(memu)
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"]
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;" )
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
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
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"])
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"]
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"])
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()
class TestStudentClassTable: with open(test_student_m_degree_dir, encoding="utf-8") as f: datas = yaml.safe_load(f) setup_datas = datas["setup_datas"] test_search_student_username_datas = datas[ "test_search_student_username"] test_get_course_bar_teachername_datas = datas[ "test_get_course_bar_teachername"] test_get_course_details_student_num_datas = datas[ "test_get_course_details_student_num"] test_search_studentname_datas = datas["test_search_studentname"] test_search_studentstaffNo_datas = datas["test_search_studentstaffNo"] test_get_lessontime_datas = datas["test_get_lessontime"] test_get_lesson_student_num_datas = datas[ "test_get_lesson_student_num"] test_back_to_student_management_degree_datas = datas[ "test_back_to_student_management_degree"] def setup_class(self): self.main = Main().goto_login(). \ username(self.setup_datas["username"]).password(self.setup_datas["password"]).save(). \ goto_application(). \ goto_classtimetable(self.setup_datas["application"]) def teardown_class(self): self.main.close() # def setup(self): # self.main = Main() # def teardown(self): # self.main.quit() @pytest.mark.parametrize("data", test_search_student_username_datas) def test_search_student_username(self, data): ''' 驗證查詢學生賬號 :return: ''' result = self.main.\ goto_student_management_degree(data["memu"]).\ search_simple(data["keywords_stu_all"]). \ choice_student().\ get_current_week_courses_num() assert result == data["expect"] @pytest.mark.parametrize("data", test_get_course_bar_teachername_datas) def test_get_course_bar_teachername(self, data): ''' 驗證卡片上的教師正確 ''' result = self.main. \ goto_student_management_degree(data["memu"]). \ search_simple(data["keywords_stu_all"]). \ choice_student(). \ get_course_bar_teachername() assert result == data["expect"] @pytest.mark.parametrize("data", test_get_course_details_student_num_datas) def test_get_course_details_student_num(self, data): ''' 驗證卡片上學生總數 :return: ''' result = self.main. \ goto_student_management_degree(data["memu"]). \ search_simple(data["keywords_stu_all"]). \ choice_student(). \ get_course_details(). \ get_course_details_student_num() assert result == data["expect"] @pytest.mark.parametrize("data", test_search_studentname_datas) def test_search_studentname(self, data): ''' 驗證班級同學頁面查詢姓名正確,必須輸入英文名稱,元素定位寫死了英文名稱 :return: ''' result = self.main. \ goto_student_management_degree(data["memu"]). \ search_simple(data["keywords_stu_all"]). \ choice_student(). \ get_course_details(). \ goto_classmate(). \ search_studentname(data["stu_keywords"]) assert result == data["expect"] @pytest.mark.parametrize("data", test_search_studentstaffNo_datas) def test_search_studentstaffNo(self, data): ''' 驗證班級同學頁面查詢學號正確 :return: ''' result = self.main. \ goto_student_management_degree(data["memu"]). \ search_simple(data["keywords_stu_all"]). \ choice_student(). \ get_course_details(). \ goto_classmate(). \ search_studentstaffNo(data["stu_keywords"]) assert result == data["expect"] @pytest.mark.parametrize("data", test_get_lessontime_datas) def test_get_lessontime(self, data): ''' 驗證班級同學頁面顯示授課時間 :return: ''' result = self.main. \ goto_student_management_degree(data["memu"]). \ search_simple(data["keywords_stu_all"]). \ choice_student(). \ get_course_details(). \ goto_classmate(). \ get_lessontime() assert result[:10] == data["expect"] @pytest.mark.parametrize("data", test_get_lesson_student_num_datas) def test_get_lesson_student_num(self, data): ''' 驗證班級同學頁面顯示人數 :return: get_lesson_student_num ''' result = self.main. \ goto_student_management_degree(data["memu"]). \ search_simple(data["keywords_stu_all"]). \ choice_student(). \ get_course_details(). \ goto_classmate(). \ get_lesson_student_num() assert result == data["expect"] @pytest.mark.parametrize("data", test_back_to_student_management_degree_datas) def test_back_to_student_management_degree(self, data): ''' 驗證班級同學頁面返回上一頁保持進入前頁面不變 :return: ''' result = self.main. \ goto_student_management_degree(data["memu"]). \ search_simple(data["keywords_stu_all"]). \ choice_student(). \ get_course_details(). \ goto_classmate(). \ back_to_student_management_degree().\ get_current_week_courses_num() assert result == data["expect"]
class Test0924: with open(test_0924_dir, encoding="utf-8") as f: datas = yaml.safe_load(f) setup_datas = datas["setup_datas"] test_get_program_datas = datas["test_get_program"] test_get_Z_M_course_teachername_datas = datas[ "test_get_Z_M_course_teachername"] test_doctor_in_records_datas = datas["test_doctor_in_records"] test_search_student_username_is_exist_datas = datas[ "test_search_student_username_is_exist"] test_search_student_username_not_exist_datas = datas[ "test_search_student_username_not_exist"] def setup_class(self): ''' 非調試端口用 ''' self.main = Main().goto_login(). \ username(self.setup_datas["username"]).password(self.setup_datas["password"]).save(). \ goto_application(). \ goto_classtimetable(self.setup_datas["application"]) def teardown_class(self): ''' 非調試端口啓用 ''' self.main.close() # def setup(self): # ''' # 開啓調試端口啓用 # ''' # self.main = Main() @pytest.mark.skip @pytest.mark.parametrize("data", test_get_program_datas) def test_get_program(self, data): ''' bug26623 驗證班級同學頁面課程字段顯示正確 ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"], data["month"], data["day"]). \ get_course_details(data["week"], data["course_num"]). \ goto_classmate(). \ get_program() assert result == data["expect"] @pytest.mark.skip @pytest.mark.parametrize("data", test_get_Z_M_course_teachername_datas) def test_get_Z_M_teachername(self, data): ''' bug26651 驗證教師課表顯示多個老師 ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"], data["month"], data["day"]). \ get_all_facCode(). \ click_advanced_search(). \ advanced_search_course_type(data["course_type"]). \ advanced_search_confirm(). \ get_course_details(data["week"], data["course_num"]). \ get_Z_M_course_teachername() assert result == data["expect"] @pytest.mark.parametrize("data", test_doctor_in_records_datas) def test_doctor_in_records(self, data): ''' bug26651 驗證教師課表顯示多個老師 ''' result = self.main. \ goto_postgraduate_sign_in_record(data["memu"]). \ search_simple(data["keywords"]). \ serach_simple_records() print(sys.path) assert result == data["expect"] @pytest.mark.parametrize("data", test_search_student_username_is_exist_datas) def test_search_student_username_is_exist(self, data): ''' bug26592驗證查詢學生賬號,本科生存在 :return: ''' result = self.main. \ goto_student_management_degree(data["memu"]). \ search_simple(data["keywords_stu_all"]). \ get_choice_value(data["expect"]) assert result == data["expect"] @pytest.mark.parametrize("data", test_search_student_username_not_exist_datas) def test_search_student_username_not_exist(self, data): ''' bug26592驗證查詢學生賬號,研究生不存在 :return: ''' result = self.main. \ goto_student_management_degree(data["memu"]). \ search_simple(data["keywords_stu_all"]). \ get_choice_value_not_exist() assert result == data["expect"]
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"]
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
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"]
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"]
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"]
class TestTeacherClassTable: with open(test_teacher_m_degree_dir, encoding="utf-8") as f: datas = yaml.safe_load(f) setup_datas = datas["setup_datas"] test_course_type_datas = datas["test_course_type"] test_simply_search_course_name_datas = datas["test_simply_search_course_name"] test_simply_search_tearch_name_datas = datas["test_simply_search_tearch_name"] test_simply_search_tearch_username_datas = datas["test_simply_search_tearch_username"] test_simply_search_course_code_datas = datas["test_simply_search_course_code"] test_advanced_search_teachername_datas = datas["test_advanced_search_teachername"] test_advanced_search_username_datas = datas["test_advanced_search_username"] test_advanced_search_room_datas = datas["test_advanced_search_room"] test_advanced_search_course_name_datas = datas["test_advanced_search_course_name"] test_advanced_search_course_code_datas = datas["test_advanced_search_course_code"] test_advanced_search_course_type_datas = datas["test_advanced_search_course_type"] test_advanced_search_reset_datas = datas["test_advanced_search_reset"] test_get_H_S_N_course_room_datas = datas["test_get_H_S_N_course_room"] test_get_H_S_N_course_zoom_datas = datas["test_get_H_S_N_course_zoom"] test_get_Z_M_course_room_datas = datas["test_get_Z_M_course_room"] test_get_course_details_student_num_datas = datas["test_get_course_details_student_num"] test_search_studentname_datas = datas["test_search_studentname"] test_search_studentstaffNo_datas = datas["test_search_studentstaffNo"] test_get_lessontime_datas = datas["test_get_lessontime"] test_get_lesson_student_num_datas = datas["test_get_lesson_student_num"] test_back_to_teacher_management_degree_datas = datas["test_back_to_teacher_management_degree"] def setup_class(self): self.main = Main().goto_login().\ username(self.setup_datas["username"]).password(self.setup_datas["password"]).save().\ goto_application().\ goto_classtimetable(self.setup_datas["application"]) def teardown_class(self): self.main.close() # def setup(self): # self.main = self.main.goto_login().\ # username(self.setup_datas["username"]).password(self.setup_datas["password"]).save().\ # goto_application().\ # goto_classtimetable(self.setup_datas["application"]) # def teardown(self): # self.main.quit() @pytest.mark.parametrize("data", test_course_type_datas) def test_course_type(self, data): ''' 驗證課堂類型 :return: ''' result = self.main. \ goto_teacher_management_degree(self.setup_datas["memu"]).\ get_yy_mm_dd(data["year"], data["month"], data["day"]). \ get_course_details(data["week"],data["course_num"]).\ get_course_type(data["data_num"]) return result == data["expect"] @pytest.mark.parametrize("data", test_simply_search_course_name_datas) def test_simply_search_course_name(self, data): ''' 驗證簡易查詢科目名稱 :return: ''' result = self.main. \ goto_teacher_management_degree(self.setup_datas["memu"]).\ get_yy_mm_dd(data["year"], data["month"], data["day"]). \ get_all_facCode(). \ simply_search(data["keywords"]).get_current_week_courses_num() assert result == data["expect"] @pytest.mark.parametrize("data", test_simply_search_tearch_name_datas) def test_simply_search_tearch_name(self, data): ''' 驗證簡易查詢教師名稱 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"],data["month"],data["day"]).\ get_all_facCode(). \ simply_search(data["keywords"]).\ get_current_week_courses_num() assert result == data["expect"] @pytest.mark.parametrize("data", test_simply_search_tearch_username_datas) def test_simply_search_tearch_username(self, data): ''' 驗證簡易查詢教師賬號 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"],data["month"],data["day"]).\ get_all_facCode(). \ simply_search(data["keywords"]).\ get_current_week_courses_num() assert result == data["expect"] @pytest.mark.parametrize("data", test_simply_search_course_code_datas) def test_simply_search_course_code(self, data): ''' 驗證簡易查詢科目編號 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"],data["month"],data["day"]).\ get_all_facCode(). \ simply_search(data["keywords"]).\ get_current_week_courses_num() assert result == data["expect"] @pytest.mark.parametrize("data", test_advanced_search_teachername_datas) def test_advanced_search_teachername(self, data): ''' 驗證高級查詢教師名稱 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"],data["month"],data["day"]).\ get_all_facCode(). \ click_advanced_search(). \ advanced_search_teachername(data["teachername"]).\ advanced_search_confirm().\ get_current_week_courses_num() assert result == data["expect"] @pytest.mark.parametrize("data", test_advanced_search_username_datas) def test_advanced_search_username(self, data): ''' 驗證高級查詢教師賬號 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"],data["month"],data["day"]).\ get_all_facCode(). \ click_advanced_search(). \ advanced_search_username(data["tusername"]).\ advanced_search_confirm().\ get_current_week_courses_num() assert result == data["expect"] @pytest.mark.parametrize("data", test_advanced_search_room_datas) def test_advanced_search_room(self, data): ''' 驗證高級查詢課室 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"],data["month"],data["day"]).\ get_all_facCode(). \ click_advanced_search(). \ advanced_search_room(data["room"]).\ advanced_search_confirm().\ get_current_week_courses_num() assert result == data["expect"] @pytest.mark.parametrize("data", test_advanced_search_course_name_datas) def test_advanced_search_course_name(self, data): ''' 驗證高級查詢科目名稱 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"],data["month"],data["day"]).\ get_all_facCode(). \ click_advanced_search(). \ advanced_search_course_name(data["course_name"]).\ advanced_search_confirm().\ get_current_week_courses_num() assert result == data["expect"] \ @pytest.mark.parametrize("data", test_advanced_search_course_code_datas) def test_advanced_search_course_code(self, data): ''' 驗證高級查詢科目編號 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"],data["month"],data["day"]).\ get_all_facCode(). \ click_advanced_search(). \ advanced_search_course_code(data["course_code"]).\ advanced_search_confirm().\ get_current_week_courses_num() assert result == data["expect"] @pytest.mark.parametrize("data", test_advanced_search_course_type_datas) def test_advanced_search_course_type(self, data): ''' 驗證高級查詢科目類型 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"],data["month"],data["day"]).\ get_all_facCode(). \ click_advanced_search(). \ advanced_search_course_type(data["course_type"]).\ advanced_search_confirm().\ get_current_week_courses_num() assert result == data["expect"] @pytest.mark.parametrize("data", test_advanced_search_reset_datas) def test_advanced_search_reset(self,data): ''' 驗證重置按鈕有效 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"],data["month"],data["day"]).\ get_all_facCode(). \ click_advanced_search(). \ advanced_search_course_code(data["course_code"]).\ advanced_search_confirm().\ advanced_search_reset().\ get_current_week_courses_num() assert result != data["expect"] @pytest.mark.parametrize("data", test_get_H_S_N_course_room_datas) def test_get_H_S_N_course_room(self, data): ''' 驗證線下課程、混合課程、特俗混合課程的課室顯示正常 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"], data["month"], data["day"]). \ get_all_facCode().\ simply_search(data["keywords"]). \ get_course_details(data["week"],data["course_num"]).\ get_H_S_N_course_room() assert result == data["expect"] @pytest.mark.parametrize("data", test_get_H_S_N_course_zoom_datas) def test_get_H_S_N_course_zoom(self, data): ''' 驗證混合課程、特俗混合課程的雲課堂顯示正常 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"], data["month"], data["day"]). \ get_all_facCode().\ simply_search(data["keywords"]). \ get_course_details(data["week"],data["course_num"]).\ get_H_S_N_course_zoom() assert result == data["expect"] @pytest.mark.parametrize("data", test_get_Z_M_course_room_datas) def test_get_Z_M_course_room(self, data): ''' 驗證雲課堂/網課的url地址顯示正常 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"], data["month"], data["day"]). \ get_all_facCode().\ simply_search(data["keywords"]). \ get_course_details(data["week"],data["course_num"]).\ get_Z_M_course_room() assert result == data["expect"] @pytest.mark.parametrize("data", test_get_course_details_student_num_datas) def test_get_course_details_student_num(self, data): ''' 驗證卡片上學生總數 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"], data["month"], data["day"]). \ get_all_facCode().\ simply_search(data["keywords"]). \ get_course_details(data["week"],data["course_num"]). \ get_course_details_student_num() assert result == data["expect"] @pytest.mark.parametrize("data", test_search_studentname_datas) def test_search_studentname(self, data): ''' 驗證班級同學頁面查詢姓名正確,必須輸入英文名稱,元素定位寫死了英文名稱 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"], data["month"], data["day"]). \ get_all_facCode().\ simply_search(data["keywords"]). \ get_course_details(data["week"],data["course_num"]). \ goto_classmate().\ search_studentname(data["stu_keywords"]) assert result == data["expect"] @pytest.mark.parametrize("data", test_search_studentstaffNo_datas) def test_search_studentstaffNo(self, data): ''' 驗證班級同學頁面查詢學號正確 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"], data["month"], data["day"]). \ get_all_facCode().\ simply_search(data["keywords"]). \ get_course_details(data["week"],data["course_num"]). \ goto_classmate().\ search_studentstaffNo(data["stu_keywords"]) assert result == data["expect"] @pytest.mark.parametrize("data", test_get_lessontime_datas) def test_get_lessontime(self, data): ''' 驗證班級同學頁面顯示授課時間 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"], data["month"], data["day"]). \ get_all_facCode().\ simply_search(data["keywords"]). \ get_course_details(data["week"],data["course_num"]). \ goto_classmate(). \ get_lessontime() assert result[:10] == data["expect"] @pytest.mark.parametrize("data", test_get_lesson_student_num_datas) def test_get_lesson_student_num(self, data): ''' 驗證班級同學頁面顯示人數 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"], data["month"], data["day"]). \ get_all_facCode().\ simply_search(data["keywords"]). \ get_course_details(data["week"],data["course_num"]). \ goto_classmate(). \ get_lesson_student_num() assert result == data["expect"] @pytest.mark.parametrize("data", test_back_to_teacher_management_degree_datas) def test_back_to_teacher_management_degree(self, data): ''' 驗證班級同學頁面返回上一頁保持進入前頁面不變 :return: ''' result = self.main. \ goto_teacher_management_degree(data["memu"]). \ get_yy_mm_dd(data["year"], data["month"], data["day"]). \ get_all_facCode().\ simply_search(data["keywords"]). \ get_course_details(data["week"],data["course_num"]). \ goto_classmate(). \ back_to_teacher_management_degree().\ get_current_week_courses_num() assert result == data["expect"]
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
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
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
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;" )