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端登录配置
82 lines
3.8 KiB
Python
82 lines
3.8 KiB
Python
# -*- coding:utf-8 -*-
|
||
"""
|
||
JoyHub C端Banner信息接口测试用例
|
||
"""
|
||
import json
|
||
import allure
|
||
import logging
|
||
import pytest
|
||
|
||
from dulizhan.library.BusinessKw.JoyHubC.BannerManage import JoyHubCBannerManage
|
||
|
||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||
|
||
|
||
@allure.feature("C端 - Banner信息模块")
|
||
class TestJoyHubCBanner:
|
||
banner_id = None
|
||
|
||
@classmethod
|
||
def setup_class(cls):
|
||
"""在整个测试类开始时初始化C端Banner业务关键字"""
|
||
logging.info("=============================================")
|
||
logging.info("=========== 开始JoyHub C端Banner信息接口测试 =========")
|
||
logging.info("=============================================")
|
||
cls.test_case = JoyHubCBannerManage()
|
||
|
||
@allure.story("验证C端获得Banner管理分页")
|
||
@allure.title("测试C端获得Banner管理分页接口")
|
||
def test_joyhub_c_banner_page_get(self):
|
||
"""测试C端获得Banner管理分页接口"""
|
||
with allure.step("1. 准备请求参数"):
|
||
params = {
|
||
"platform": 1,
|
||
"lang": "en",
|
||
"pageNo": 1,
|
||
"pageSize": 10
|
||
}
|
||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||
|
||
with allure.step("2. 调用获得Banner管理分页接口"):
|
||
resp = self.test_case.kw_joyhub_c_banner_page_get(**params)
|
||
allure.attach(json.dumps(resp, ensure_ascii=False, indent=2), name="响应数据", attachment_type=allure.attachment_type.JSON)
|
||
|
||
with allure.step("3. 验证响应"):
|
||
assert resp is not None, "响应为空"
|
||
assert "code" in resp, "响应中缺少code字段"
|
||
assert resp["code"] == 0, f"请求失败,code={resp.get('code')}, msg={resp.get('msg')}"
|
||
assert "data" in resp, "响应中缺少data字段"
|
||
assert "list" in resp["data"], "响应中缺少list字段"
|
||
assert isinstance(resp["data"]["list"], list), "list字段不是列表类型"
|
||
if "total" in resp["data"]:
|
||
assert isinstance(resp["data"]["total"], int), "total字段不是整数类型"
|
||
if resp["data"]["list"]:
|
||
TestJoyHubCBanner.banner_id = resp["data"]["list"][0].get("id")
|
||
logging.info("C端获得Banner管理分页接口验证通过")
|
||
|
||
@allure.story("验证C端获得Banner管理")
|
||
@allure.title("测试C端获得Banner管理接口")
|
||
def test_joyhub_c_banner_get_get(self):
|
||
"""测试C端获得Banner管理接口"""
|
||
if not TestJoyHubCBanner.banner_id:
|
||
pytest.skip("没有可用于查询详情的Banner数据")
|
||
|
||
with allure.step("1. 准备请求参数"):
|
||
params = {
|
||
"id": TestJoyHubCBanner.banner_id
|
||
}
|
||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||
|
||
with allure.step("2. 调用获得Banner管理接口"):
|
||
resp = self.test_case.kw_joyhub_c_banner_get_get(**params)
|
||
allure.attach(json.dumps(resp, ensure_ascii=False, indent=2), name="响应数据", attachment_type=allure.attachment_type.JSON)
|
||
|
||
with allure.step("3. 验证响应"):
|
||
assert resp is not None, "响应为空"
|
||
assert "code" in resp, "响应中缺少code字段"
|
||
assert resp["code"] == 0, f"请求失败,code={resp.get('code')}, msg={resp.get('msg')}"
|
||
assert "data" in resp, "响应中缺少data字段"
|
||
assert resp["data"] is not None, "data字段为空"
|
||
assert resp["data"].get("id") == TestJoyHubCBanner.banner_id, "返回的Banner ID与请求ID不一致"
|
||
logging.info("C端获得Banner管理接口验证通过")
|