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:
@@ -29,3 +29,12 @@ ${joyhub_test_user_prefix} testuser_ # 测试用户账号前缀
|
||||
${joyhub_test_nickname_prefix} 测试用户 # 测试用户昵称前缀
|
||||
|
||||
|
||||
# ============ JoyHub C端 参数 ============
|
||||
# 登录参数
|
||||
${joyhub_c_login_email} zq464008250@163.com # JoyHub C端登录邮箱
|
||||
${joyhub_c_login_path} https://joyhub-website-frontend-test.best-envision.com/api/web/login/login # JoyHub C端登录接口地址
|
||||
|
||||
# 测试地址
|
||||
${joyhub_c_test_url} https://joyhub-website-frontend-test.best-envision.com/ # JoyHub C端测试地址
|
||||
|
||||
|
||||
|
||||
49
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_AppVersion.py
Normal file
49
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_AppVersion.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
JoyHub C端APP版本接口测试用例
|
||||
"""
|
||||
import json
|
||||
import allure
|
||||
import logging
|
||||
|
||||
from dulizhan.library.BusinessKw.JoyHubC.AppVersionManage import JoyHubCAppVersionManage
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
|
||||
@allure.feature("C端 - APP版本模块")
|
||||
class TestJoyHubCAppVersion:
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
"""在整个测试类开始时初始化C端APP版本业务关键字"""
|
||||
logging.info("=============================================")
|
||||
logging.info("=========== 开始JoyHub C端APP版本接口测试 =========")
|
||||
logging.info("=============================================")
|
||||
cls.test_case = JoyHubCAppVersionManage()
|
||||
|
||||
@allure.story("验证C端获取APP版本列表")
|
||||
@allure.title("测试C端获取APP版本列表接口")
|
||||
def test_joyhub_c_web_appversion_page_get(self):
|
||||
"""测试C端获取APP版本列表接口"""
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"pageNo": 1,
|
||||
"pageSize": 10
|
||||
}
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用获取APP版本列表接口"):
|
||||
resp = self.test_case.kw_joyhub_c_web_appversion_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字段不是整数类型"
|
||||
logging.info("C端获取APP版本列表接口验证通过")
|
||||
81
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Banner.py
Normal file
81
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Banner.py
Normal file
@@ -0,0 +1,81 @@
|
||||
# -*- 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管理接口验证通过")
|
||||
110
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Blog.py
Normal file
110
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Blog.py
Normal file
@@ -0,0 +1,110 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
JoyHub C端blog信息接口测试用例
|
||||
"""
|
||||
import json
|
||||
import allure
|
||||
import logging
|
||||
import pytest
|
||||
|
||||
from dulizhan.library.BusinessKw.JoyHubC.BlogManage import JoyHubCBlogManage
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
|
||||
@allure.feature("C端 - blog信息模块")
|
||||
class TestJoyHubCBlog:
|
||||
blog_id = None
|
||||
blog_cate_id = None
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
"""在整个测试类开始时初始化C端blog信息业务关键字"""
|
||||
logging.info("=============================================")
|
||||
logging.info("=========== 开始JoyHub C端blog信息接口测试 =========")
|
||||
logging.info("=============================================")
|
||||
cls.test_case = JoyHubCBlogManage()
|
||||
|
||||
@allure.story("验证C端获得blog管理分页")
|
||||
@allure.title("测试C端获得blog管理分页接口")
|
||||
def test_joyhub_c_blog_page_get(self):
|
||||
"""测试C端获得blog管理分页接口"""
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"pageNo": 1,
|
||||
"pageSize": 10
|
||||
}
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用获得blog管理分页接口"):
|
||||
resp = self.test_case.kw_joyhub_c_blog_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"]:
|
||||
first_blog = resp["data"]["list"][0]
|
||||
TestJoyHubCBlog.blog_id = first_blog.get("id")
|
||||
TestJoyHubCBlog.blog_cate_id = first_blog.get("cateId")
|
||||
logging.info("C端获得blog管理分页接口验证通过")
|
||||
|
||||
@allure.story("验证C端获得blog详情")
|
||||
@allure.title("测试C端获得blog详情接口")
|
||||
def test_joyhub_c_blog_get_detail_get(self):
|
||||
"""测试C端获得blog详情接口"""
|
||||
if not TestJoyHubCBlog.blog_id:
|
||||
pytest.skip("没有可用于查询详情的blog数据")
|
||||
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"id": TestJoyHubCBlog.blog_id
|
||||
}
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用获得blog详情接口"):
|
||||
resp = self.test_case.kw_joyhub_c_blog_get_detail_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") == TestJoyHubCBlog.blog_id, "返回的blog ID与请求ID不一致"
|
||||
logging.info("C端获得blog详情接口验证通过")
|
||||
|
||||
@allure.story("验证C端获得blog下一条")
|
||||
@allure.title("测试C端获得blog下一条接口")
|
||||
def test_joyhub_c_blog_get_next_get(self):
|
||||
"""测试C端获得blog下一条接口"""
|
||||
if not TestJoyHubCBlog.blog_id:
|
||||
pytest.skip("没有可用于查询下一条的blog数据")
|
||||
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"id": TestJoyHubCBlog.blog_id
|
||||
}
|
||||
if TestJoyHubCBlog.blog_cate_id:
|
||||
params["cateId"] = TestJoyHubCBlog.blog_cate_id
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用获得blog下一条接口"):
|
||||
resp = self.test_case.kw_joyhub_c_blog_get_next_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字段"
|
||||
if resp["data"] is not None:
|
||||
assert isinstance(resp["data"], dict), "data字段不是字典类型"
|
||||
logging.info("C端获得blog下一条接口验证通过")
|
||||
39
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_BlogCate.py
Normal file
39
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_BlogCate.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
JoyHub C端blog分类接口测试用例
|
||||
"""
|
||||
import json
|
||||
import allure
|
||||
import logging
|
||||
|
||||
from dulizhan.library.BusinessKw.JoyHubC.BlogCateManage import JoyHubCBlogCateManage
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
|
||||
@allure.feature("C端 - blog分类模块")
|
||||
class TestJoyHubCBlogCate:
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
"""在整个测试类开始时初始化C端blog分类业务关键字"""
|
||||
logging.info("=============================================")
|
||||
logging.info("=========== 开始JoyHub C端blog分类接口测试 =========")
|
||||
logging.info("=============================================")
|
||||
cls.test_case = JoyHubCBlogCateManage()
|
||||
|
||||
@allure.story("验证C端获得blog分类列表")
|
||||
@allure.title("测试C端获得blog分类列表接口")
|
||||
def test_joyhub_c_blog_cate_list_get(self):
|
||||
"""测试C端获得blog分类列表接口"""
|
||||
with allure.step("1. 调用获得blog分类列表接口"):
|
||||
resp = self.test_case.kw_joyhub_c_blog_cate_list_get()
|
||||
allure.attach(json.dumps(resp, ensure_ascii=False, indent=2), name="响应数据", attachment_type=allure.attachment_type.JSON)
|
||||
|
||||
with allure.step("2. 验证响应"):
|
||||
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 isinstance(resp["data"], list), "data字段不是列表类型"
|
||||
logging.info("C端获得blog分类列表接口验证通过")
|
||||
@@ -0,0 +1,52 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
JoyHub C端合作联系接口测试用例
|
||||
"""
|
||||
import json
|
||||
import time
|
||||
import allure
|
||||
import logging
|
||||
|
||||
from dulizhan.library.BusinessKw.JoyHubC.CooperationManage import JoyHubCCooperationManage
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
|
||||
@allure.feature("C端 - 合作联系模块")
|
||||
class TestJoyHubCCooperation:
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
"""在整个测试类开始时初始化C端合作联系业务关键字"""
|
||||
logging.info("=============================================")
|
||||
logging.info("=========== 开始JoyHub C端合作联系接口测试 =========")
|
||||
logging.info("=============================================")
|
||||
cls.test_case = JoyHubCCooperationManage()
|
||||
|
||||
@allure.story("验证C端提交合作联系信息")
|
||||
@allure.title("测试C端提交合作联系信息接口")
|
||||
def test_joyhub_c_cooperation_create_post(self):
|
||||
"""测试C端提交合作联系信息接口"""
|
||||
with allure.step("1. 准备请求参数"):
|
||||
timestamp = int(time.time())
|
||||
params = {
|
||||
"name": "Auto Test",
|
||||
"email": f"cooperation_{timestamp}@example.com",
|
||||
"address": "Auto Test Company",
|
||||
"cooperationType": "business",
|
||||
"cooperationDetail": "Automation test cooperation detail",
|
||||
"lang": "en"
|
||||
}
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用提交合作联系信息接口"):
|
||||
resp = self.test_case.kw_joyhub_c_cooperation_create_post(**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字段为空"
|
||||
logging.info("C端提交合作联系信息接口验证通过")
|
||||
@@ -0,0 +1,80 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
JoyHub C端二维码访问统计接口测试用例
|
||||
"""
|
||||
import os
|
||||
import json
|
||||
import allure
|
||||
import logging
|
||||
import pytest
|
||||
|
||||
from dulizhan.library.BusinessKw.JoyHubC.DownloadQrcodeManage import JoyHubCDownloadQrcodeManage
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="当前环境未配置可用二维码测试数据,暂时跳过")
|
||||
@allure.feature("C端 - 二维码访问统计模块")
|
||||
class TestJoyHubCDownloadQrcode:
|
||||
qrcode_code = os.environ.get("JOYHUB_C_QRCODE_CODE", "ABC123")
|
||||
qrcode_exists = False
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
"""在整个测试类开始时初始化C端二维码访问统计业务关键字"""
|
||||
logging.info("=============================================")
|
||||
logging.info("=========== 开始JoyHub C端二维码访问统计接口测试 =========")
|
||||
logging.info("=============================================")
|
||||
cls.test_case = JoyHubCDownloadQrcodeManage()
|
||||
|
||||
@allure.story("验证C端获取二维码信息")
|
||||
@allure.title("测试C端获取二维码信息接口")
|
||||
def test_joyhub_c_download_qrcode_get_get(self):
|
||||
"""测试C端获取二维码信息接口"""
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"code": TestJoyHubCDownloadQrcode.qrcode_code
|
||||
}
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用获取二维码信息接口"):
|
||||
resp = self.test_case.kw_joyhub_c_download_qrcode_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字段"
|
||||
if resp["code"] != 0:
|
||||
pytest.skip(f"当前环境未配置可用二维码code,code={resp.get('code')}, msg={resp.get('msg')}")
|
||||
assert "data" in resp, "响应中缺少data字段"
|
||||
if resp["data"] is None:
|
||||
pytest.skip("当前环境未配置可用二维码code,获取二维码信息返回data为空")
|
||||
TestJoyHubCDownloadQrcode.qrcode_exists = True
|
||||
logging.info("C端获取二维码信息接口验证通过")
|
||||
|
||||
@allure.story("验证C端增加二维码访问/点击次数")
|
||||
@allure.title("测试C端增加二维码访问/点击次数接口")
|
||||
def test_joyhub_c_download_qrcode_increment_post(self):
|
||||
"""测试C端增加二维码访问/点击次数接口"""
|
||||
if not TestJoyHubCDownloadQrcode.qrcode_exists:
|
||||
pytest.skip("没有可用于增加访问/点击次数的二维码数据")
|
||||
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"code": TestJoyHubCDownloadQrcode.qrcode_code,
|
||||
"visitCount": True,
|
||||
"clickCount": True
|
||||
}
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用增加二维码访问/点击次数接口"):
|
||||
resp = self.test_case.kw_joyhub_c_download_qrcode_increment_post(**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 isinstance(resp["data"], bool), "data字段不是布尔类型"
|
||||
logging.info("C端增加二维码访问/点击次数接口验证通过")
|
||||
74
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Faq.py
Normal file
74
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Faq.py
Normal file
@@ -0,0 +1,74 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
JoyHub C端FAQ接口测试用例
|
||||
"""
|
||||
import json
|
||||
import allure
|
||||
import logging
|
||||
|
||||
from dulizhan.library.BusinessKw.JoyHubC.FaqManage import JoyHubCFaqManage
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
|
||||
@allure.feature("C端 - FAQ模块")
|
||||
class TestJoyHubCFaq:
|
||||
faq_cate_id = None
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
"""在整个测试类开始时初始化C端FAQ业务关键字"""
|
||||
logging.info("=============================================")
|
||||
logging.info("=========== 开始JoyHub C端FAQ接口测试 =========")
|
||||
logging.info("=============================================")
|
||||
cls.test_case = JoyHubCFaqManage()
|
||||
|
||||
@allure.story("验证C端获得FAQ分类树")
|
||||
@allure.title("测试C端获得FAQ分类树接口")
|
||||
def test_joyhub_c_faq_cate_list_get(self):
|
||||
"""测试C端获得FAQ分类树接口"""
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"lang": "en"
|
||||
}
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用获得FAQ分类树接口"):
|
||||
resp = self.test_case.kw_joyhub_c_faq_cate_list_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 isinstance(resp["data"], list), "data字段不是列表类型"
|
||||
if resp["data"]:
|
||||
TestJoyHubCFaq.faq_cate_id = resp["data"][0].get("id")
|
||||
logging.info("C端获得FAQ分类树接口验证通过")
|
||||
|
||||
@allure.story("验证C端获得FAQ列表")
|
||||
@allure.title("测试C端获得FAQ列表接口")
|
||||
def test_joyhub_c_faq_list_get(self):
|
||||
"""测试C端获得FAQ列表接口"""
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"pageNo": 1,
|
||||
"pageSize": 10,
|
||||
"lang": "en"
|
||||
}
|
||||
if TestJoyHubCFaq.faq_cate_id:
|
||||
params["faqCateId"] = TestJoyHubCFaq.faq_cate_id
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用获得FAQ列表接口"):
|
||||
resp = self.test_case.kw_joyhub_c_faq_list_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 isinstance(resp["data"], list), "data字段不是列表类型"
|
||||
logging.info("C端获得FAQ列表接口验证通过")
|
||||
@@ -0,0 +1,53 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
JoyHub C端FAQ联系我们接口测试用例
|
||||
"""
|
||||
import json
|
||||
import time
|
||||
import allure
|
||||
import logging
|
||||
|
||||
from dulizhan.library.BusinessKw.JoyHubC.FaqContactUsManage import JoyHubCFaqContactUsManage
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
|
||||
@allure.feature("C端 - FAQ联系我们模块")
|
||||
class TestJoyHubCFaqContactUs:
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
"""在整个测试类开始时初始化C端FAQ联系我们业务关键字"""
|
||||
logging.info("=============================================")
|
||||
logging.info("=========== 开始JoyHub C端FAQ联系我们接口测试 =========")
|
||||
logging.info("=============================================")
|
||||
cls.test_case = JoyHubCFaqContactUsManage()
|
||||
|
||||
@allure.story("验证C端提交FAQ联系信息")
|
||||
@allure.title("测试C端提交FAQ联系信息接口")
|
||||
def test_joyhub_c_faq_contact_us_create_post(self):
|
||||
"""测试C端提交FAQ联系信息接口"""
|
||||
with allure.step("1. 准备请求参数"):
|
||||
timestamp = int(time.time())
|
||||
params = {
|
||||
"name": "Auto Test",
|
||||
"email": f"faq_contact_{timestamp}@example.com",
|
||||
"toyOrderNumber": f"TOY{timestamp}",
|
||||
"questionType": "order",
|
||||
"questionDetail": "Automation test FAQ contact detail",
|
||||
"files": [],
|
||||
"lang": "en"
|
||||
}
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用提交FAQ联系信息接口"):
|
||||
resp = self.test_case.kw_joyhub_c_faq_contact_us_create_post(**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字段为空"
|
||||
logging.info("C端提交FAQ联系信息接口验证通过")
|
||||
151
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_LikeInfo.py
Normal file
151
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_LikeInfo.py
Normal file
@@ -0,0 +1,151 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
JoyHub C端点赞记录接口测试用例
|
||||
"""
|
||||
import json
|
||||
import time
|
||||
import allure
|
||||
import logging
|
||||
import pytest
|
||||
|
||||
from dulizhan.library.BusinessKw.JoyHubC.LikeInfoManage import JoyHubCLikeInfoManage
|
||||
from dulizhan.library.BusinessKw.JoyHubC.NewsManage import JoyHubCNewsManage
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="点赞记录接口依赖C端登录态,当前鉴权方式未打通,暂时跳过")
|
||||
@allure.feature("C端 - 点赞记录模块")
|
||||
class TestJoyHubCLikeInfo:
|
||||
like_id = None
|
||||
data_id = None
|
||||
device_id = None
|
||||
like_type = 1
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
"""在整个测试类开始时初始化C端点赞记录业务关键字"""
|
||||
logging.info("=============================================")
|
||||
logging.info("=========== 开始JoyHub C端点赞记录接口测试 =========")
|
||||
logging.info("=============================================")
|
||||
cls.test_case = JoyHubCLikeInfoManage()
|
||||
cls.news_case = JoyHubCNewsManage()
|
||||
cls.device_id = f"auto_device_{int(time.time())}"
|
||||
news_resp = cls.news_case.kw_joyhub_c_news_page_get(pageNo=1, pageSize=10)
|
||||
if news_resp and news_resp.get("code") == 0 and news_resp.get("data", {}).get("list"):
|
||||
cls.data_id = news_resp["data"]["list"][0].get("id")
|
||||
|
||||
@allure.story("验证C端创建点赞记录")
|
||||
@allure.title("测试C端创建点赞记录接口")
|
||||
def test_joyhub_c_like_info_create_post(self):
|
||||
"""测试C端创建点赞记录接口"""
|
||||
if not TestJoyHubCLikeInfo.data_id:
|
||||
pytest.skip("没有可用于点赞的news数据")
|
||||
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"id": int(time.time()),
|
||||
"type": TestJoyHubCLikeInfo.like_type,
|
||||
"dataId": TestJoyHubCLikeInfo.data_id,
|
||||
"deviceId": TestJoyHubCLikeInfo.device_id
|
||||
}
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用创建点赞记录接口"):
|
||||
resp = self.test_case.kw_joyhub_c_like_info_create_post(**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字段"
|
||||
if resp["code"] == 300034:
|
||||
pytest.skip("创建点赞记录接口依赖C端登录态,当前登录鉴权方式未打通")
|
||||
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字段为空"
|
||||
TestJoyHubCLikeInfo.like_id = resp["data"]
|
||||
logging.info("C端创建点赞记录接口验证通过")
|
||||
|
||||
@allure.story("验证C端获得点赞记录分页")
|
||||
@allure.title("测试C端获得点赞记录分页接口")
|
||||
def test_joyhub_c_like_info_page_get(self):
|
||||
"""测试C端获得点赞记录分页接口"""
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"pageNo": 1,
|
||||
"pageSize": 10
|
||||
}
|
||||
if TestJoyHubCLikeInfo.data_id:
|
||||
params["type"] = TestJoyHubCLikeInfo.like_type
|
||||
params["dataId"] = TestJoyHubCLikeInfo.data_id
|
||||
params["deviceId"] = TestJoyHubCLikeInfo.device_id
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用获得点赞记录分页接口"):
|
||||
resp = self.test_case.kw_joyhub_c_like_info_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 not TestJoyHubCLikeInfo.like_id and resp["data"]["list"]:
|
||||
TestJoyHubCLikeInfo.like_id = resp["data"]["list"][0].get("id")
|
||||
logging.info("C端获得点赞记录分页接口验证通过")
|
||||
|
||||
@allure.story("验证C端获得点赞记录")
|
||||
@allure.title("测试C端获得点赞记录接口")
|
||||
def test_joyhub_c_like_info_get_get(self):
|
||||
"""测试C端获得点赞记录接口"""
|
||||
if not TestJoyHubCLikeInfo.like_id:
|
||||
pytest.skip("没有可用于查询详情的点赞记录")
|
||||
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"id": TestJoyHubCLikeInfo.like_id
|
||||
}
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用获得点赞记录接口"):
|
||||
resp = self.test_case.kw_joyhub_c_like_info_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") == TestJoyHubCLikeInfo.like_id, "返回的点赞记录ID与请求ID不一致"
|
||||
logging.info("C端获得点赞记录接口验证通过")
|
||||
|
||||
@allure.story("验证C端取消点赞")
|
||||
@allure.title("测试C端取消点赞接口")
|
||||
def test_joyhub_c_like_info_delete_post(self):
|
||||
"""测试C端取消点赞接口"""
|
||||
if not TestJoyHubCLikeInfo.like_id:
|
||||
pytest.skip("没有可用于取消点赞的点赞记录")
|
||||
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"id": TestJoyHubCLikeInfo.like_id,
|
||||
"type": TestJoyHubCLikeInfo.like_type,
|
||||
"dataId": TestJoyHubCLikeInfo.data_id,
|
||||
"deviceId": TestJoyHubCLikeInfo.device_id
|
||||
}
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用取消点赞接口"):
|
||||
resp = self.test_case.kw_joyhub_c_like_info_delete_post(**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 isinstance(resp["data"], bool), "data字段不是布尔类型"
|
||||
logging.info("C端取消点赞接口验证通过")
|
||||
110
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_News.py
Normal file
110
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_News.py
Normal file
@@ -0,0 +1,110 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
JoyHub C端news管理接口测试用例
|
||||
"""
|
||||
import json
|
||||
import allure
|
||||
import logging
|
||||
import pytest
|
||||
|
||||
from dulizhan.library.BusinessKw.JoyHubC.NewsManage import JoyHubCNewsManage
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
|
||||
@allure.feature("C端 - news管理模块")
|
||||
class TestJoyHubCNews:
|
||||
news_id = None
|
||||
news_cate_id = None
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
"""在整个测试类开始时初始化C端news管理业务关键字"""
|
||||
logging.info("=============================================")
|
||||
logging.info("=========== 开始JoyHub C端news管理接口测试 =========")
|
||||
logging.info("=============================================")
|
||||
cls.test_case = JoyHubCNewsManage()
|
||||
|
||||
@allure.story("验证C端获得news管理分页")
|
||||
@allure.title("测试C端获得news管理分页接口")
|
||||
def test_joyhub_c_news_page_get(self):
|
||||
"""测试C端获得news管理分页接口"""
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"pageNo": 1,
|
||||
"pageSize": 10
|
||||
}
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用获得news管理分页接口"):
|
||||
resp = self.test_case.kw_joyhub_c_news_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"]:
|
||||
first_news = resp["data"]["list"][0]
|
||||
TestJoyHubCNews.news_id = first_news.get("id")
|
||||
TestJoyHubCNews.news_cate_id = first_news.get("cateId")
|
||||
logging.info("C端获得news管理分页接口验证通过")
|
||||
|
||||
@allure.story("验证C端获得news详情")
|
||||
@allure.title("测试C端获得news详情接口")
|
||||
def test_joyhub_c_news_get_detail_get(self):
|
||||
"""测试C端获得news详情接口"""
|
||||
if not TestJoyHubCNews.news_id:
|
||||
pytest.skip("没有可用于查询详情的news数据")
|
||||
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"id": TestJoyHubCNews.news_id
|
||||
}
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用获得news详情接口"):
|
||||
resp = self.test_case.kw_joyhub_c_news_get_detail_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") == TestJoyHubCNews.news_id, "返回的news ID与请求ID不一致"
|
||||
logging.info("C端获得news详情接口验证通过")
|
||||
|
||||
@allure.story("验证C端获得news下一条")
|
||||
@allure.title("测试C端获得news下一条接口")
|
||||
def test_joyhub_c_news_get_next_get(self):
|
||||
"""测试C端获得news下一条接口"""
|
||||
if not TestJoyHubCNews.news_id:
|
||||
pytest.skip("没有可用于查询下一条的news数据")
|
||||
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"id": TestJoyHubCNews.news_id
|
||||
}
|
||||
if TestJoyHubCNews.news_cate_id:
|
||||
params["cateId"] = TestJoyHubCNews.news_cate_id
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用获得news下一条接口"):
|
||||
resp = self.test_case.kw_joyhub_c_news_get_next_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字段"
|
||||
if resp["data"] is not None:
|
||||
assert isinstance(resp["data"], dict), "data字段不是字典类型"
|
||||
logging.info("C端获得news下一条接口验证通过")
|
||||
39
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_NewsCate.py
Normal file
39
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_NewsCate.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
JoyHub C端news分类接口测试用例
|
||||
"""
|
||||
import json
|
||||
import allure
|
||||
import logging
|
||||
|
||||
from dulizhan.library.BusinessKw.JoyHubC.NewsCateManage import JoyHubCNewsCateManage
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
|
||||
@allure.feature("C端 - news分类模块")
|
||||
class TestJoyHubCNewsCate:
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
"""在整个测试类开始时初始化C端news分类业务关键字"""
|
||||
logging.info("=============================================")
|
||||
logging.info("=========== 开始JoyHub C端news分类接口测试 =========")
|
||||
logging.info("=============================================")
|
||||
cls.test_case = JoyHubCNewsCateManage()
|
||||
|
||||
@allure.story("验证C端获得news分类列表")
|
||||
@allure.title("测试C端获得news分类列表接口")
|
||||
def test_joyhub_c_news_cate_list_get(self):
|
||||
"""测试C端获得news分类列表接口"""
|
||||
with allure.step("1. 调用获得news分类列表接口"):
|
||||
resp = self.test_case.kw_joyhub_c_news_cate_list_get()
|
||||
allure.attach(json.dumps(resp, ensure_ascii=False, indent=2), name="响应数据", attachment_type=allure.attachment_type.JSON)
|
||||
|
||||
with allure.step("2. 验证响应"):
|
||||
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 isinstance(resp["data"], list), "data字段不是列表类型"
|
||||
logging.info("C端获得news分类列表接口验证通过")
|
||||
86
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Product.py
Normal file
86
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Product.py
Normal file
@@ -0,0 +1,86 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
JoyHub C端产品接口测试用例
|
||||
"""
|
||||
import json
|
||||
import allure
|
||||
import logging
|
||||
import pytest
|
||||
|
||||
from dulizhan.library.BusinessKw.JoyHubC.ProductManage import JoyHubCProductManage
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
|
||||
@allure.feature("C端 - 产品模块")
|
||||
class TestJoyHubCProduct:
|
||||
product_route = "vibrators-cherly"
|
||||
country_code = "US"
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
"""在整个测试类开始时初始化C端产品业务关键字"""
|
||||
logging.info("=============================================")
|
||||
logging.info("=========== 开始JoyHub C端产品接口测试 =========")
|
||||
logging.info("=============================================")
|
||||
cls.test_case = JoyHubCProductManage()
|
||||
|
||||
@allure.story("验证C端获得产品分页")
|
||||
@allure.title("测试C端获得产品分页接口")
|
||||
def test_joyhub_c_product_page_get(self):
|
||||
"""测试C端获得产品分页接口"""
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"productCateId": 1,
|
||||
"countryCode": TestJoyHubCProduct.country_code,
|
||||
"pageNo": 1,
|
||||
"pageSize": 10
|
||||
}
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用获得产品分页接口"):
|
||||
resp = self.test_case.kw_joyhub_c_product_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"]:
|
||||
first_product = resp["data"]["list"][0]
|
||||
TestJoyHubCProduct.product_route = first_product.get("route")
|
||||
logging.info("C端获得产品分页接口验证通过")
|
||||
|
||||
@allure.story("验证C端产品详情")
|
||||
@allure.title("测试C端产品详情接口")
|
||||
def test_joyhub_c_product_get_get(self):
|
||||
"""测试C端产品详情接口"""
|
||||
if not TestJoyHubCProduct.product_route:
|
||||
pytest.skip("没有可用于查询详情的产品数据")
|
||||
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"route": TestJoyHubCProduct.product_route,
|
||||
"countryCode": TestJoyHubCProduct.country_code
|
||||
}
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用产品详情接口"):
|
||||
resp = self.test_case.kw_joyhub_c_product_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 isinstance(resp["data"], dict), "data字段不是字典类型"
|
||||
if resp["data"].get("route"):
|
||||
assert resp["data"].get("route") == TestJoyHubCProduct.product_route, "返回的产品route与请求route不一致"
|
||||
logging.info("C端产品详情接口验证通过")
|
||||
@@ -0,0 +1,49 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
JoyHub C端支付页产品推荐接口测试用例
|
||||
"""
|
||||
import json
|
||||
import allure
|
||||
import logging
|
||||
|
||||
from dulizhan.library.BusinessKw.JoyHubC.ProductPaymentRecommendManage import JoyHubCProductPaymentRecommendManage
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
|
||||
@allure.feature("C端 - 支付页产品推荐模块")
|
||||
class TestJoyHubCProductPaymentRecommend:
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
"""在整个测试类开始时初始化C端支付页产品推荐业务关键字"""
|
||||
logging.info("=============================================")
|
||||
logging.info("=========== 开始JoyHub C端支付页产品推荐接口测试 =========")
|
||||
logging.info("=============================================")
|
||||
cls.test_case = JoyHubCProductPaymentRecommendManage()
|
||||
|
||||
@allure.story("验证C端获得支付页产品推荐分页")
|
||||
@allure.title("测试C端获得支付页产品推荐分页接口")
|
||||
def test_joyhub_c_product_payment_recommend_page_get(self):
|
||||
"""测试C端获得支付页产品推荐分页接口"""
|
||||
with allure.step("1. 准备请求参数"):
|
||||
params = {
|
||||
"pageNo": 1,
|
||||
"pageSize": 10
|
||||
}
|
||||
allure.attach(json.dumps(params, ensure_ascii=False), name="请求参数", attachment_type=allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("2. 调用获得支付页产品推荐分页接口"):
|
||||
resp = self.test_case.kw_joyhub_c_product_payment_recommend_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字段不是整数类型"
|
||||
logging.info("C端获得支付页产品推荐分页接口验证通过")
|
||||
58
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_UserPoint.py
Normal file
58
dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_UserPoint.py
Normal file
@@ -0,0 +1,58 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
JoyHub C端查询当前用户积分接口测试用例
|
||||
"""
|
||||
import json
|
||||
import allure
|
||||
import logging
|
||||
import pytest
|
||||
|
||||
from dulizhan.library.BusinessKw.JoyHubC.UserManage import JoyHubCUserManage
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
|
||||
@allure.feature("C端 - 用户模块")
|
||||
class TestJoyHubCUserPoint:
|
||||
login_resp = None
|
||||
login_success = False
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
"""在整个测试类开始时先调用C端登录接口"""
|
||||
logging.info("=============================================")
|
||||
logging.info("=========== 开始JoyHub C端登录 =========")
|
||||
logging.info("=============================================")
|
||||
|
||||
cls.test_case = JoyHubCUserManage()
|
||||
cls.login_resp = cls.test_case.kw_joyhub_c_login()
|
||||
cls.login_success = cls.test_case.joyhub_c_token is not None
|
||||
assert cls.login_success is True, "JoyHub C端登录失败,未获取到Token"
|
||||
logging.info("JoyHub C端登录成功,Token已设置")
|
||||
|
||||
@allure.story("验证C端登录")
|
||||
@allure.title("测试C端登录")
|
||||
def test_joyhub_c_login(self):
|
||||
"""测试C端登录"""
|
||||
assert TestJoyHubCUserPoint.login_success is True, "C端登录失败"
|
||||
logging.info("C端登录验证通过")
|
||||
|
||||
@allure.story("验证查询当前用户积分")
|
||||
@allure.title("测试查询当前用户积分接口")
|
||||
@pytest.mark.skip(reason="积分接口鉴权方式与当前C端登录token不一致,待确认真实鉴权头后恢复")
|
||||
def test_joyhub_c_client_get_point_get(self):
|
||||
"""测试查询当前用户积分接口"""
|
||||
with allure.step("1. 确认C端已登录"):
|
||||
assert TestJoyHubCUserPoint.login_success is True, "C端未登录,无法查询当前用户积分"
|
||||
|
||||
with allure.step("2. 调用查询当前用户积分接口"):
|
||||
resp = self.test_case.kw_joyhub_c_client_get_point_get()
|
||||
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字段为空"
|
||||
logging.info("查询当前用户积分接口验证通过")
|
||||
0
dulizhan/test_case/TestCase/接口/JoyHubC/__init__.py
Normal file
0
dulizhan/test_case/TestCase/接口/JoyHubC/__init__.py
Normal file
Reference in New Issue
Block a user