feat: 新增JoyHub C端测试用例和接口封装

1. 新增C端业务关键字层 (JoyHubC/):
   - LoginManage.py - C端登录管理
   - UserManage.py - C端用户管理
   - ProductManage.py - C端产品管理
   - BannerManage.py - C端Banner管理
   - AppVersionManage.py - C端版本管理等

2. 新增C端测试用例 (TestCase/接口/JoyHubC/):
   - JoyhubC_UserPoint.py - 用户积分测试
   - JoyhubC_Product.py - 产品测试
   - JoyhubC_Banner.py - Banner测试等

3. 接口层增强:
   - Dlizhan_interface.py 添加C端接口封装
   - 添加网易163邮箱验证码获取功能

4. 配置更新:
   - hh-qa.robot 添加C端登录配置
This commit is contained in:
2026-05-13 15:56:41 +08:00
parent 3191ec4f3c
commit 37a040c3e5
33 changed files with 1830 additions and 4 deletions

View File

@@ -0,0 +1,84 @@
# -*- coding:utf-8 -*-
import os
import re
import time
import allure
from base_framework.public_tools import log
from dulizhan.library.Dlizhan_interface import DlzhanInterface
obj_log = log.get_logger()
class JoyHubCLoginManage(DlzhanInterface):
def __init__(self):
super().__init__()
test_url = self._read_robot_variable("joyhub_c_test_url")
if test_url:
self.joyhub_c_frontend_url = test_url
def _read_robot_variable(self, var_name):
robot_file_path = os.path.join(
os.path.dirname(__file__),
'../../../test_case/Resource/AdapterKws/hh-qa.robot'
)
try:
with open(robot_file_path, 'r', encoding='utf-8') as f:
content = f.read()
pattern = r'\$\{' + re.escape(var_name) + r'\}\s+(\S+)'
match = re.search(pattern, content)
if match:
return match.group(1)
except Exception as e:
obj_log.error("读取robot配置文件失败: {}".format(str(e)))
return None
@allure.step("获取JoyHub C端邮箱验证码")
def kw_joyhub_c_get_email_code(self, email=None, code_pattern=r'\d{4,8}'):
email = email or self._read_robot_variable("joyhub_c_login_email")
if not email:
raise Exception("C端登录邮箱不能为空请检查 joyhub_c_login_email 配置")
obj_log.info("获取JoyHub C端邮箱验证码 - email: {}".format(email))
code = self.kw_in_joyhub_c_get_email_code(email, code_pattern)
obj_log.info("获取JoyHub C端邮箱验证码成功")
return code
@allure.step("JoyHub C端登录")
def kw_joyhub_c_login(self, path=None, email=None, code=None, is_check='true', **kwargs):
email = email or self._read_robot_variable("joyhub_c_login_email")
path = path or self._read_robot_variable("joyhub_c_login_path")
if not email:
raise Exception("C端登录邮箱不能为空请检查 joyhub_c_login_email 配置")
if not path:
raise Exception("C端登录接口路径不能为空请检查 joyhub_c_login_path 配置")
code = code or "123456"
params = {
"email": email,
"valid_code": code,
"sys_type": "windows",
"app_channel": "5",
"lang": "en",
"client_time": str(int(time.time()))
}
params.update(kwargs)
obj_log.info("JoyHub C端登录 - email: {}, path: {}".format(email, path))
resp = self.kw_in_joyhub_c_login_post(path=path, is_check=is_check, **params)
data = resp.get('data') if isinstance(resp, dict) else None
token = None
if isinstance(data, dict):
token = data.get('accessToken') or data.get('access_token') or data.get('token')
token = token or resp.get('accessToken') if isinstance(resp, dict) else token
token = token or resp.get('access_token') if isinstance(resp, dict) else token
token = token or resp.get('token') if isinstance(resp, dict) else token
if token:
self.set_joyhub_c_token(token)
obj_log.info("JoyHub C端登录成功Token已写入当前实例")
else:
obj_log.warning("JoyHub C端登录响应中未解析到Token")
return resp