Update test framework: fix run_tests.py to support all test files, add auto-import-check for test files

This commit is contained in:
qiaoxinjiu
2026-05-09 15:11:30 +08:00
parent eb053a347f
commit eaba8328da
21739 changed files with 2236758 additions and 719 deletions

View File

@@ -0,0 +1,137 @@
from airtest.core.api import *
import logging
import allure
import sys
import subprocess
import shutil
LOCAL_PATH = os.path.dirname(os.path.abspath(__file__))
BASE_PROJECT_PATH = os.path.abspath(os.path.join(LOCAL_PATH, '../../../../../../{}'.format("UBRD")))
BASIC_PATH = os.path.abspath(os.path.join(LOCAL_PATH, '../../../../../../'))
sys.path.append(BASE_PROJECT_PATH)
sys.path.append(BASIC_PATH)
from ui_library.page.teacher.home.teacher_home import TeacherHome
from ui_library.page.student.huohua.PC.view.view import View
from library.CommonFun.host_update import HostUpdate,CoreApollo
from ui_library.page.teacher.login.teacher_login import TeacherLogin
from ui_library.page.teacher.classroom.teacher_classroom import TeacherClassroom
host_update = HostUpdate()
obj_core_apollo = CoreApollo()
@allure.feature('Teacher')
class TestTeacherClassroom:
def setup(self):
self.host_list = []
# 重启nginx
file_path = r"C:\Users\Administrator\AppData\Roaming\peppa-app-pc-teacher-sim\db.json"
source_file = r"C:\Users\Administrator\AppData\Roaming\st-teacher\db.json"
if os.path.isfile(file_path):
os.remove(file_path)
shutil.copy(source_file, file_path)
subprocess.Popen(['C:\\Program Files (x86)\\peppa-app-pc-teacher-sim\\Huohua Teacher - sim\\火花教师端 - SIM版.exe'])
sleep(15)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维*"])
TeacherHome().login_out()
def teardown(self):
for i in self.host_list:
host_update.host_remove_intercept(i["ip"],i["host_name"])
os.system("ipconfig /flushdns")
subprocess.call(['taskkill', '/F', '/IM', '火花教师端 - SIM版.exe'])
@allure.title("[教师前端磐石正常密码登录成功--001]")
def test_student_login_by_pwd_normal(self):
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维*"])
with allure.step("清除客户端缓存"):
file_path = r"C:\Users\Administrator\AppData\Roaming\peppa-app-pc-teacher-sim\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
with allure.step("清除前端缓存"):
View().input_console_command("window.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("输入手机号"):
TeacherLogin().input_phone("13540133074")
with allure.step("输入密码"):
TeacherLogin().input_pwd("Mima@123")
with allure.step("点击登录按钮"):
TeacherLogin().click_login_button()
sleep(20)
with allure.step("确认登录成功"):
TeacherHome().assert_login_in()
@allure.title("[教师前端域名降级--002]")
def test_student_login_by_pwd_low_fe(self):
with allure.step("添加域名屏蔽"):
file_path = r"C:\Users\Administrator\AppData\Roaming\peppa-app-pc-teacher-sim\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', '火花教师端 - SIM版.exe'])
subprocess.Popen(['C:\\Program Files (x86)\\peppa-app-pc-teacher-sim\\Huohua Teacher - sim\\火花教师端 - SIM版.exe'])
sleep(15)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维*"])
TeacherHome().login_out()
with allure.step("清除前端缓存"):
View().input_console_command("window.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("点击通过验证码登录"):
TeacherLogin().click_by_code()
with allure.step("输入手机号"):
TeacherLogin().input_phone("15890630602")
with allure.step("验证码输入"):
TeacherLogin().input_code("8334")
sleep(5)
with allure.step("点击登录按钮"):
TeacherLogin().click_login_button()
sleep(5)
with allure.step("点击登录按钮"):
TeacherLogin().click_login_button()
sleep(5)
with allure.step("点击登录按钮"):
TeacherLogin().click_login_button()
sleep(5)
with allure.step("确认登录成功"):
sleep(20)
TeacherHome().assert_login_in()
@allure.title("[教师端PC强制登录进入课堂上课--003]")
def test_teacher_join_classroom_check(self):
with allure.step("添加域名重定向"):
ip = host_update.get_ip_by_host_domain(domain="core-api-check.sim.huohua.cn")
self.host_list = [{"ip": "127.0.0.1", "host_name": "core-api.sim.huohua.cn"}]
host_update.host_update_by_host_dict(self.host_list)
host_update.wait_dns_flush(ip="127.0.0.1" ,domain= "core-api.sim.huohua.cn")
file_path = r"C:\Users\Administrator\AppData\Roaming\peppa-app-pc-teacher-sim\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', '火花教师端 - SIM版.exe'])
subprocess.Popen(['C:\\Program Files (x86)\\peppa-app-pc-teacher-sim\\Huohua Teacher - sim\\火花教师端 - SIM版.exe'])
sleep(15)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维*"])
TeacherHome().login_out()
with allure.step("清除前端缓存"):
View().input_console_command("window.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("点击通过验证码登录"):
TeacherLogin().click_by_code()
with allure.step("输入手机号"):
TeacherLogin().input_phone("15890630602")
with allure.step("验证码输入"):
TeacherLogin().input_code("8334")
sleep(5)
with allure.step("点击登录按钮"):
TeacherLogin().click_login_button()
sleep(5)
with allure.step("点击进入课堂"):
TeacherHome().click_join_classrom()
sleep(60)
with allure.step("点击全选并开始"):
TeacherClassroom().click_all_label()
with allure.step("点击开始上课"):
TeacherClassroom().click_start_classroom()
sleep(5)
with allure.step("点击下课"):
TeacherClassroom().close_classroom()
sleep(10)

View File

@@ -0,0 +1,142 @@
from airtest.core.api import *
import logging
import allure
import sys
import subprocess
import shutil
LOCAL_PATH = os.path.dirname(os.path.abspath(__file__))
BASE_PROJECT_PATH = os.path.abspath(os.path.join(LOCAL_PATH, '../../../../../../{}'.format("UBRD")))
BASIC_PATH = os.path.abspath(os.path.join(LOCAL_PATH, '../../../../../../'))
sys.path.append(BASE_PROJECT_PATH)
sys.path.append(BASIC_PATH)
from ui_library.page.teacher.home.teacher_home import TeacherHome
from ui_library.page.student.huohua.PC.view.view import View
from library.CommonFun.host_update import HostUpdate,CoreApollo
from ui_library.page.teacher.login.teacher_login import TeacherLogin
from ui_library.page.teacher.classroom.teacher_classroom import TeacherClassroom
host_update = HostUpdate()
obj_core_apollo = CoreApollo()
@allure.feature('Teacher')
class TestTeacherClassroom:
def setup(self):
self.host_list = []
# 重启nginx
file_path = r"C:\Users\Administrator\AppData\Roaming\huohua-teacher-client\db.json"
source_file = r"C:\Users\Administrator\AppData\Roaming\on_teacher\db.json"
if os.path.isfile(file_path):
os.remove(file_path)
shutil.copy(source_file, file_path)
subprocess.Popen(['C:\\Program Files (x86)\\Huohua Teacher\\Huohua Teacher.exe'])
sleep(15)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维*"])
TeacherHome().login_out()
def teardown(self):
for i in self.host_list:
host_update.host_remove_intercept(i["ip"],i["host_name"])
os.system("ipconfig /flushdns")
subprocess.call(['taskkill', '/F', '/IM', 'Huohua Teacher.exe'])
@allure.title("[教师前端磐石正常密码登录成功--001]")
def test_student_login_by_pwd_normal(self):
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维*"])
with allure.step("清除客户端缓存"):
file_path = r"C:\Users\Administrator\AppData\Roaming\huohua-teacher-client\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
with allure.step("清除前端缓存"):
View().input_console_command("window.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("输入手机号"):
TeacherLogin().input_phone("13540133074")
with allure.step("输入密码"):
TeacherLogin().input_pwd("Mima@123")
with allure.step("点击登录按钮"):
default_status = TeacherLogin().get_login_button()
if default_status:
TeacherLogin().click_login_button()
sleep(10)
with allure.step("确认登录成功"):
TeacherHome().assert_login_in()
@allure.title("[教师前端域名降级--002]")
def test_student_login_by_pwd_low_fe(self):
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维*"])
with allure.step("清除客户端缓存"):
file_path = r"C:\Users\Administrator\AppData\Roaming\huohua-teacher-client\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', 'Huohua Teacher.exe'])
subprocess.Popen(['C:\\Program Files (x86)\\Huohua Teacher\\Huohua Teacher.exe'])
sleep(10)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维*"])
TeacherHome().login_out()
with allure.step("清除前端缓存 域名重新轮询"):
View().input_console_command("window.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("点击通过验证码登录"):
TeacherLogin().click_by_code()
with allure.step("输入手机号"):
TeacherLogin().input_phone("15890630602")
with allure.step("验证码输入"):
TeacherLogin().input_code("8334")
with allure.step("第一次点击登录按钮"):
TeacherLogin().click_login_button()
sleep(5)
with allure.step("第二次点击登录按钮"):
TeacherLogin().click_login_button()
sleep(10)
with allure.step("第三次点击登录按钮"):
TeacherLogin().click_login_button()
sleep(10)
with allure.step("第四次点击登录按钮"):
TeacherLogin().click_login_button()
sleep(10)
with allure.step("确认登录成功"):
TeacherHome().assert_login_in()
@allure.title("[教师端PC强制登录进入课堂上课--003]")
def test_teacher_join_classroom_check(self):
with allure.step("添加域名重定向"):
self.host_list = [{"ip": "127.0.0.1", "host_name": "core-api.huohua.cn"}]
host_update.host_update_by_host_dict(self.host_list)
host_update.wait_dns_flush(ip="127.0.0.1" ,domain= "core-api.huohua.cn")
file_path = r"C:\Users\Administrator\AppData\Roaming\huohua-teacher-client\kmm_cache_db.json"
if os.path.isfile(file_path):
os.remove(file_path)
subprocess.call(['taskkill', '/F', '/IM', 'Huohua Teacher.exe'])
subprocess.Popen(['C:\\Program Files (x86)\\Huohua Teacher\\Huohua Teacher.exe'])
sleep(10)
auto_setup(__file__, logdir=True, devices=["Windows:///?title_re=.*火花思维*"])
TeacherHome().login_out()
with allure.step("清除前端缓存"):
View().input_console_command("window.localStorage.removeItem{(}'POP_STORAGE_TYPE'{)}")
with allure.step("点击通过验证码登录"):
TeacherLogin().click_by_code()
with allure.step("输入手机号"):
TeacherLogin().input_phone("15890630602")
with allure.step("验证码输入"):
TeacherLogin().input_code("8334")
with allure.step("点击登录按钮"):
default_status = TeacherLogin().get_login_button()
if default_status:
TeacherLogin().click_login_button()
sleep(10)
with allure.step("点击进入课堂"):
TeacherHome().click_join_classrom()
sleep(30)
with allure.step("点击全选并开始"):
TeacherClassroom().click_all_label()
with allure.step("点击开始上课"):
TeacherClassroom().click_start_classroom()
sleep(5)
with allure.step("点击下课"):
TeacherClassroom().close_classroom()
sleep(10)