From 37a040c3e51acf77f8635988ae6bc60ccc7f325c Mon Sep 17 00:00:00 2001 From: zhouqi Date: Wed, 13 May 2026 15:56:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9EJoyHub=20C=E7=AB=AF?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E5=92=8C=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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端登录配置 --- .../BusinessKw/JoyHubC/AppVersionManage.py | 27 +++ .../BusinessKw/JoyHubC/BannerManage.py | 38 ++++ .../BusinessKw/JoyHubC/BlogCateManage.py | 27 +++ .../library/BusinessKw/JoyHubC/BlogManage.py | 49 ++++ .../BusinessKw/JoyHubC/CooperationManage.py | 27 +++ .../JoyHubC/DownloadQrcodeManage.py | 38 ++++ .../BusinessKw/JoyHubC/FaqContactUsManage.py | 27 +++ .../library/BusinessKw/JoyHubC/FaqManage.py | 38 ++++ .../BusinessKw/JoyHubC/LikeInfoManage.py | 60 +++++ .../library/BusinessKw/JoyHubC/LoginManage.py | 84 +++++++ .../BusinessKw/JoyHubC/NewsCateManage.py | 27 +++ .../library/BusinessKw/JoyHubC/NewsManage.py | 49 ++++ .../BusinessKw/JoyHubC/ProductManage.py | 38 ++++ .../JoyHubC/ProductPaymentRecommendManage.py | 27 +++ .../library/BusinessKw/JoyHubC/UserManage.py | 27 +++ .../library/BusinessKw/JoyHubC/__init__.py | 1 + dulizhan/library/Dlizhan_interface.py | 210 +++++++++++++++++- .../test_case/Resource/AdapterKws/hh-qa.robot | 9 + .../接口/JoyHubC/JoyhubC_AppVersion.py | 49 ++++ .../TestCase/接口/JoyHubC/JoyhubC_Banner.py | 81 +++++++ .../TestCase/接口/JoyHubC/JoyhubC_Blog.py | 110 +++++++++ .../TestCase/接口/JoyHubC/JoyhubC_BlogCate.py | 39 ++++ .../接口/JoyHubC/JoyhubC_Cooperation.py | 52 +++++ .../接口/JoyHubC/JoyhubC_DownloadQrcode.py | 80 +++++++ .../TestCase/接口/JoyHubC/JoyhubC_Faq.py | 74 ++++++ .../接口/JoyHubC/JoyhubC_FaqContactUs.py | 53 +++++ .../TestCase/接口/JoyHubC/JoyhubC_LikeInfo.py | 151 +++++++++++++ .../TestCase/接口/JoyHubC/JoyhubC_News.py | 110 +++++++++ .../TestCase/接口/JoyHubC/JoyhubC_NewsCate.py | 39 ++++ .../TestCase/接口/JoyHubC/JoyhubC_Product.py | 86 +++++++ .../JoyHubC/JoyhubC_ProductPaymentRecommend.py | 49 ++++ .../接口/JoyHubC/JoyhubC_UserPoint.py | 58 +++++ .../TestCase/接口/JoyHubC/__init__.py | 0 33 files changed, 1830 insertions(+), 4 deletions(-) create mode 100644 dulizhan/library/BusinessKw/JoyHubC/AppVersionManage.py create mode 100644 dulizhan/library/BusinessKw/JoyHubC/BannerManage.py create mode 100644 dulizhan/library/BusinessKw/JoyHubC/BlogCateManage.py create mode 100644 dulizhan/library/BusinessKw/JoyHubC/BlogManage.py create mode 100644 dulizhan/library/BusinessKw/JoyHubC/CooperationManage.py create mode 100644 dulizhan/library/BusinessKw/JoyHubC/DownloadQrcodeManage.py create mode 100644 dulizhan/library/BusinessKw/JoyHubC/FaqContactUsManage.py create mode 100644 dulizhan/library/BusinessKw/JoyHubC/FaqManage.py create mode 100644 dulizhan/library/BusinessKw/JoyHubC/LikeInfoManage.py create mode 100644 dulizhan/library/BusinessKw/JoyHubC/LoginManage.py create mode 100644 dulizhan/library/BusinessKw/JoyHubC/NewsCateManage.py create mode 100644 dulizhan/library/BusinessKw/JoyHubC/NewsManage.py create mode 100644 dulizhan/library/BusinessKw/JoyHubC/ProductManage.py create mode 100644 dulizhan/library/BusinessKw/JoyHubC/ProductPaymentRecommendManage.py create mode 100644 dulizhan/library/BusinessKw/JoyHubC/UserManage.py create mode 100644 dulizhan/library/BusinessKw/JoyHubC/__init__.py create mode 100644 dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_AppVersion.py create mode 100644 dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Banner.py create mode 100644 dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Blog.py create mode 100644 dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_BlogCate.py create mode 100644 dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Cooperation.py create mode 100644 dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_DownloadQrcode.py create mode 100644 dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Faq.py create mode 100644 dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_FaqContactUs.py create mode 100644 dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_LikeInfo.py create mode 100644 dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_News.py create mode 100644 dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_NewsCate.py create mode 100644 dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Product.py create mode 100644 dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_ProductPaymentRecommend.py create mode 100644 dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_UserPoint.py create mode 100644 dulizhan/test_case/TestCase/接口/JoyHubC/__init__.py diff --git a/dulizhan/library/BusinessKw/JoyHubC/AppVersionManage.py b/dulizhan/library/BusinessKw/JoyHubC/AppVersionManage.py new file mode 100644 index 0000000..42af804 --- /dev/null +++ b/dulizhan/library/BusinessKw/JoyHubC/AppVersionManage.py @@ -0,0 +1,27 @@ +# -*- coding:utf-8 -*- +""" +JoyHub C端APP版本业务关键字层 +""" +import allure +from dulizhan.library.BusinessKw.JoyHubC.LoginManage import JoyHubCLoginManage +from base_framework.public_tools import log + +obj_log = log.get_logger() + + +class JoyHubCAppVersionManage(JoyHubCLoginManage): + """JoyHub C端APP版本业务关键字类""" + + def __init__(self): + super().__init__() + + @allure.step("获取APP版本列表") + def kw_joyhub_c_web_appversion_page_get(self, **kwargs): + """ + 获取APP版本列表业务关键字 + :return: 响应结果 + """ + obj_log.info("获取APP版本列表") + resp = self.kw_in_joyhub_c_web_appversion_page_get(**kwargs) + obj_log.info(f"获取APP版本列表响应: {resp}") + return resp diff --git a/dulizhan/library/BusinessKw/JoyHubC/BannerManage.py b/dulizhan/library/BusinessKw/JoyHubC/BannerManage.py new file mode 100644 index 0000000..368cb83 --- /dev/null +++ b/dulizhan/library/BusinessKw/JoyHubC/BannerManage.py @@ -0,0 +1,38 @@ +# -*- coding:utf-8 -*- +""" +JoyHub C端Banner信息业务关键字层 +""" +import allure +from dulizhan.library.BusinessKw.JoyHubC.LoginManage import JoyHubCLoginManage +from base_framework.public_tools import log + +obj_log = log.get_logger() + + +class JoyHubCBannerManage(JoyHubCLoginManage): + """JoyHub C端Banner信息业务关键字类""" + + def __init__(self): + super().__init__() + + @allure.step("获得Banner管理") + def kw_joyhub_c_banner_get_get(self, **kwargs): + """ + 获得Banner管理业务关键字 + :return: 响应结果 + """ + obj_log.info("获得Banner管理") + resp = self.kw_in_joyhub_c_banner_get_get(**kwargs) + obj_log.info(f"获得Banner管理响应: {resp}") + return resp + + @allure.step("获得Banner管理分页") + def kw_joyhub_c_banner_page_get(self, **kwargs): + """ + 获得Banner管理分页业务关键字 + :return: 响应结果 + """ + obj_log.info("获得Banner管理分页") + resp = self.kw_in_joyhub_c_banner_page_get(**kwargs) + obj_log.info(f"获得Banner管理分页响应: {resp}") + return resp diff --git a/dulizhan/library/BusinessKw/JoyHubC/BlogCateManage.py b/dulizhan/library/BusinessKw/JoyHubC/BlogCateManage.py new file mode 100644 index 0000000..42ac587 --- /dev/null +++ b/dulizhan/library/BusinessKw/JoyHubC/BlogCateManage.py @@ -0,0 +1,27 @@ +# -*- coding:utf-8 -*- +""" +JoyHub C端blog分类业务关键字层 +""" +import allure +from dulizhan.library.BusinessKw.JoyHubC.LoginManage import JoyHubCLoginManage +from base_framework.public_tools import log + +obj_log = log.get_logger() + + +class JoyHubCBlogCateManage(JoyHubCLoginManage): + """JoyHub C端blog分类业务关键字类""" + + def __init__(self): + super().__init__() + + @allure.step("获得blog分类列表") + def kw_joyhub_c_blog_cate_list_get(self, **kwargs): + """ + 获得blog分类列表业务关键字 + :return: 响应结果 + """ + obj_log.info("获得blog分类列表") + resp = self.kw_in_joyhub_c_blog_cate_list_get(**kwargs) + obj_log.info(f"获得blog分类列表响应: {resp}") + return resp diff --git a/dulizhan/library/BusinessKw/JoyHubC/BlogManage.py b/dulizhan/library/BusinessKw/JoyHubC/BlogManage.py new file mode 100644 index 0000000..1c78b4e --- /dev/null +++ b/dulizhan/library/BusinessKw/JoyHubC/BlogManage.py @@ -0,0 +1,49 @@ +# -*- coding:utf-8 -*- +""" +JoyHub C端blog信息业务关键字层 +""" +import allure +from dulizhan.library.BusinessKw.JoyHubC.LoginManage import JoyHubCLoginManage +from base_framework.public_tools import log + +obj_log = log.get_logger() + + +class JoyHubCBlogManage(JoyHubCLoginManage): + """JoyHub C端blog信息业务关键字类""" + + def __init__(self): + super().__init__() + + @allure.step("获得blog详情") + def kw_joyhub_c_blog_get_detail_get(self, **kwargs): + """ + 获得blog详情业务关键字 + :return: 响应结果 + """ + obj_log.info("获得blog详情") + resp = self.kw_in_joyhub_c_blog_get_detail_get(**kwargs) + obj_log.info(f"获得blog详情响应: {resp}") + return resp + + @allure.step("获得blog下一条") + def kw_joyhub_c_blog_get_next_get(self, **kwargs): + """ + 获得blog下一条业务关键字 + :return: 响应结果 + """ + obj_log.info("获得blog下一条") + resp = self.kw_in_joyhub_c_blog_get_next_get(**kwargs) + obj_log.info(f"获得blog下一条响应: {resp}") + return resp + + @allure.step("获得blog管理分页") + def kw_joyhub_c_blog_page_get(self, **kwargs): + """ + 获得blog管理分页业务关键字 + :return: 响应结果 + """ + obj_log.info("获得blog管理分页") + resp = self.kw_in_joyhub_c_blog_page_get(**kwargs) + obj_log.info(f"获得blog管理分页响应: {resp}") + return resp diff --git a/dulizhan/library/BusinessKw/JoyHubC/CooperationManage.py b/dulizhan/library/BusinessKw/JoyHubC/CooperationManage.py new file mode 100644 index 0000000..2edb044 --- /dev/null +++ b/dulizhan/library/BusinessKw/JoyHubC/CooperationManage.py @@ -0,0 +1,27 @@ +# -*- coding:utf-8 -*- +""" +JoyHub C端合作联系业务关键字层 +""" +import allure +from dulizhan.library.BusinessKw.JoyHubC.LoginManage import JoyHubCLoginManage +from base_framework.public_tools import log + +obj_log = log.get_logger() + + +class JoyHubCCooperationManage(JoyHubCLoginManage): + """JoyHub C端合作联系业务关键字类""" + + def __init__(self): + super().__init__() + + @allure.step("提交合作联系信息") + def kw_joyhub_c_cooperation_create_post(self, **kwargs): + """ + 提交合作联系信息业务关键字 + :return: 响应结果 + """ + obj_log.info("提交合作联系信息") + resp = self.kw_in_joyhub_c_cooperation_create_post(**kwargs) + obj_log.info(f"提交合作联系信息响应: {resp}") + return resp diff --git a/dulizhan/library/BusinessKw/JoyHubC/DownloadQrcodeManage.py b/dulizhan/library/BusinessKw/JoyHubC/DownloadQrcodeManage.py new file mode 100644 index 0000000..831543a --- /dev/null +++ b/dulizhan/library/BusinessKw/JoyHubC/DownloadQrcodeManage.py @@ -0,0 +1,38 @@ +# -*- coding:utf-8 -*- +""" +JoyHub C端二维码访问统计业务关键字层 +""" +import allure +from dulizhan.library.BusinessKw.JoyHubC.LoginManage import JoyHubCLoginManage +from base_framework.public_tools import log + +obj_log = log.get_logger() + + +class JoyHubCDownloadQrcodeManage(JoyHubCLoginManage): + """JoyHub C端二维码访问统计业务关键字类""" + + def __init__(self): + super().__init__() + + @allure.step("获取二维码信息") + def kw_joyhub_c_download_qrcode_get_get(self, **kwargs): + """ + 获取二维码信息业务关键字 + :return: 响应结果 + """ + obj_log.info("获取二维码信息") + resp = self.kw_in_joyhub_c_download_qrcode_get_get(**kwargs) + obj_log.info(f"获取二维码信息响应: {resp}") + return resp + + @allure.step("增加二维码访问/点击次数") + def kw_joyhub_c_download_qrcode_increment_post(self, **kwargs): + """ + 增加二维码访问/点击次数业务关键字 + :return: 响应结果 + """ + obj_log.info("增加二维码访问/点击次数") + resp = self.kw_in_joyhub_c_download_qrcode_increment_post(**kwargs) + obj_log.info(f"增加二维码访问/点击次数响应: {resp}") + return resp diff --git a/dulizhan/library/BusinessKw/JoyHubC/FaqContactUsManage.py b/dulizhan/library/BusinessKw/JoyHubC/FaqContactUsManage.py new file mode 100644 index 0000000..885dbae --- /dev/null +++ b/dulizhan/library/BusinessKw/JoyHubC/FaqContactUsManage.py @@ -0,0 +1,27 @@ +# -*- coding:utf-8 -*- +""" +JoyHub C端FAQ联系我们业务关键字层 +""" +import allure +from dulizhan.library.BusinessKw.JoyHubC.LoginManage import JoyHubCLoginManage +from base_framework.public_tools import log + +obj_log = log.get_logger() + + +class JoyHubCFaqContactUsManage(JoyHubCLoginManage): + """JoyHub C端FAQ联系我们业务关键字类""" + + def __init__(self): + super().__init__() + + @allure.step("提交FAQ联系信息") + def kw_joyhub_c_faq_contact_us_create_post(self, **kwargs): + """ + 提交FAQ联系信息业务关键字 + :return: 响应结果 + """ + obj_log.info("提交FAQ联系信息") + resp = self.kw_in_joyhub_c_faq_contact_us_create_post(**kwargs) + obj_log.info(f"提交FAQ联系信息响应: {resp}") + return resp diff --git a/dulizhan/library/BusinessKw/JoyHubC/FaqManage.py b/dulizhan/library/BusinessKw/JoyHubC/FaqManage.py new file mode 100644 index 0000000..3ce88f7 --- /dev/null +++ b/dulizhan/library/BusinessKw/JoyHubC/FaqManage.py @@ -0,0 +1,38 @@ +# -*- coding:utf-8 -*- +""" +JoyHub C端FAQ业务关键字层 +""" +import allure +from dulizhan.library.BusinessKw.JoyHubC.LoginManage import JoyHubCLoginManage +from base_framework.public_tools import log + +obj_log = log.get_logger() + + +class JoyHubCFaqManage(JoyHubCLoginManage): + """JoyHub C端FAQ业务关键字类""" + + def __init__(self): + super().__init__() + + @allure.step("获得FAQ分类树") + def kw_joyhub_c_faq_cate_list_get(self, **kwargs): + """ + 获得FAQ分类树业务关键字 + :return: 响应结果 + """ + obj_log.info("获得FAQ分类树") + resp = self.kw_in_joyhub_c_faq_cate_list_get(**kwargs) + obj_log.info(f"获得FAQ分类树响应: {resp}") + return resp + + @allure.step("获得FAQ列表") + def kw_joyhub_c_faq_list_get(self, **kwargs): + """ + 获得FAQ列表业务关键字 + :return: 响应结果 + """ + obj_log.info("获得FAQ列表") + resp = self.kw_in_joyhub_c_faq_list_get(**kwargs) + obj_log.info(f"获得FAQ列表响应: {resp}") + return resp diff --git a/dulizhan/library/BusinessKw/JoyHubC/LikeInfoManage.py b/dulizhan/library/BusinessKw/JoyHubC/LikeInfoManage.py new file mode 100644 index 0000000..b03cca0 --- /dev/null +++ b/dulizhan/library/BusinessKw/JoyHubC/LikeInfoManage.py @@ -0,0 +1,60 @@ +# -*- coding:utf-8 -*- +""" +JoyHub C端点赞记录业务关键字层 +""" +import allure +from dulizhan.library.BusinessKw.JoyHubC.LoginManage import JoyHubCLoginManage +from base_framework.public_tools import log + +obj_log = log.get_logger() + + +class JoyHubCLikeInfoManage(JoyHubCLoginManage): + """JoyHub C端点赞记录业务关键字类""" + + def __init__(self): + super().__init__() + + @allure.step("创建点赞记录") + def kw_joyhub_c_like_info_create_post(self, **kwargs): + """ + 创建点赞记录业务关键字 + :return: 响应结果 + """ + obj_log.info("创建点赞记录") + resp = self.kw_in_joyhub_c_like_info_create_post(**kwargs) + obj_log.info(f"创建点赞记录响应: {resp}") + return resp + + @allure.step("取消点赞") + def kw_joyhub_c_like_info_delete_post(self, **kwargs): + """ + 取消点赞业务关键字 + :return: 响应结果 + """ + obj_log.info("取消点赞") + resp = self.kw_in_joyhub_c_like_info_delete_post(**kwargs) + obj_log.info(f"取消点赞响应: {resp}") + return resp + + @allure.step("获得点赞记录") + def kw_joyhub_c_like_info_get_get(self, **kwargs): + """ + 获得点赞记录业务关键字 + :return: 响应结果 + """ + obj_log.info("获得点赞记录") + resp = self.kw_in_joyhub_c_like_info_get_get(**kwargs) + obj_log.info(f"获得点赞记录响应: {resp}") + return resp + + @allure.step("获得点赞记录分页") + def kw_joyhub_c_like_info_page_get(self, **kwargs): + """ + 获得点赞记录分页业务关键字 + :return: 响应结果 + """ + obj_log.info("获得点赞记录分页") + resp = self.kw_in_joyhub_c_like_info_page_get(**kwargs) + obj_log.info(f"获得点赞记录分页响应: {resp}") + return resp diff --git a/dulizhan/library/BusinessKw/JoyHubC/LoginManage.py b/dulizhan/library/BusinessKw/JoyHubC/LoginManage.py new file mode 100644 index 0000000..aca1a11 --- /dev/null +++ b/dulizhan/library/BusinessKw/JoyHubC/LoginManage.py @@ -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 diff --git a/dulizhan/library/BusinessKw/JoyHubC/NewsCateManage.py b/dulizhan/library/BusinessKw/JoyHubC/NewsCateManage.py new file mode 100644 index 0000000..07a5cf8 --- /dev/null +++ b/dulizhan/library/BusinessKw/JoyHubC/NewsCateManage.py @@ -0,0 +1,27 @@ +# -*- coding:utf-8 -*- +""" +JoyHub C端news分类业务关键字层 +""" +import allure +from dulizhan.library.BusinessKw.JoyHubC.LoginManage import JoyHubCLoginManage +from base_framework.public_tools import log + +obj_log = log.get_logger() + + +class JoyHubCNewsCateManage(JoyHubCLoginManage): + """JoyHub C端news分类业务关键字类""" + + def __init__(self): + super().__init__() + + @allure.step("获得news分类列表") + def kw_joyhub_c_news_cate_list_get(self, **kwargs): + """ + 获得news分类列表业务关键字 + :return: 响应结果 + """ + obj_log.info("获得news分类列表") + resp = self.kw_in_joyhub_c_news_cate_list_get(**kwargs) + obj_log.info(f"获得news分类列表响应: {resp}") + return resp diff --git a/dulizhan/library/BusinessKw/JoyHubC/NewsManage.py b/dulizhan/library/BusinessKw/JoyHubC/NewsManage.py new file mode 100644 index 0000000..2db8e7b --- /dev/null +++ b/dulizhan/library/BusinessKw/JoyHubC/NewsManage.py @@ -0,0 +1,49 @@ +# -*- coding:utf-8 -*- +""" +JoyHub C端news管理业务关键字层 +""" +import allure +from dulizhan.library.BusinessKw.JoyHubC.LoginManage import JoyHubCLoginManage +from base_framework.public_tools import log + +obj_log = log.get_logger() + + +class JoyHubCNewsManage(JoyHubCLoginManage): + """JoyHub C端news管理业务关键字类""" + + def __init__(self): + super().__init__() + + @allure.step("获得news详情") + def kw_joyhub_c_news_get_detail_get(self, **kwargs): + """ + 获得news详情业务关键字 + :return: 响应结果 + """ + obj_log.info("获得news详情") + resp = self.kw_in_joyhub_c_news_get_detail_get(**kwargs) + obj_log.info(f"获得news详情响应: {resp}") + return resp + + @allure.step("获得news下一条") + def kw_joyhub_c_news_get_next_get(self, **kwargs): + """ + 获得news下一条业务关键字 + :return: 响应结果 + """ + obj_log.info("获得news下一条") + resp = self.kw_in_joyhub_c_news_get_next_get(**kwargs) + obj_log.info(f"获得news下一条响应: {resp}") + return resp + + @allure.step("获得news管理分页") + def kw_joyhub_c_news_page_get(self, **kwargs): + """ + 获得news管理分页业务关键字 + :return: 响应结果 + """ + obj_log.info("获得news管理分页") + resp = self.kw_in_joyhub_c_news_page_get(**kwargs) + obj_log.info(f"获得news管理分页响应: {resp}") + return resp diff --git a/dulizhan/library/BusinessKw/JoyHubC/ProductManage.py b/dulizhan/library/BusinessKw/JoyHubC/ProductManage.py new file mode 100644 index 0000000..abd984b --- /dev/null +++ b/dulizhan/library/BusinessKw/JoyHubC/ProductManage.py @@ -0,0 +1,38 @@ +# -*- coding:utf-8 -*- +""" +JoyHub C端产品业务关键字层 +""" +import allure +from dulizhan.library.BusinessKw.JoyHubC.LoginManage import JoyHubCLoginManage +from base_framework.public_tools import log + +obj_log = log.get_logger() + + +class JoyHubCProductManage(JoyHubCLoginManage): + """JoyHub C端产品业务关键字类""" + + def __init__(self): + super().__init__() + + @allure.step("产品详情") + def kw_joyhub_c_product_get_get(self, **kwargs): + """ + 产品详情业务关键字 + :return: 响应结果 + """ + obj_log.info("产品详情") + resp = self.kw_in_joyhub_c_product_get_get(**kwargs) + obj_log.info(f"产品详情响应: {resp}") + return resp + + @allure.step("获得产品分页") + def kw_joyhub_c_product_page_get(self, **kwargs): + """ + 获得产品分页业务关键字 + :return: 响应结果 + """ + obj_log.info("获得产品分页") + resp = self.kw_in_joyhub_c_product_page_get(**kwargs) + obj_log.info(f"获得产品分页响应: {resp}") + return resp diff --git a/dulizhan/library/BusinessKw/JoyHubC/ProductPaymentRecommendManage.py b/dulizhan/library/BusinessKw/JoyHubC/ProductPaymentRecommendManage.py new file mode 100644 index 0000000..b50ba08 --- /dev/null +++ b/dulizhan/library/BusinessKw/JoyHubC/ProductPaymentRecommendManage.py @@ -0,0 +1,27 @@ +# -*- coding:utf-8 -*- +""" +JoyHub C端支付页产品推荐业务关键字层 +""" +import allure +from dulizhan.library.BusinessKw.JoyHubC.LoginManage import JoyHubCLoginManage +from base_framework.public_tools import log + +obj_log = log.get_logger() + + +class JoyHubCProductPaymentRecommendManage(JoyHubCLoginManage): + """JoyHub C端支付页产品推荐业务关键字类""" + + def __init__(self): + super().__init__() + + @allure.step("获得支付页产品推荐分页") + def kw_joyhub_c_product_payment_recommend_page_get(self, **kwargs): + """ + 获得支付页产品推荐分页业务关键字 + :return: 响应结果 + """ + obj_log.info("获得支付页产品推荐分页") + resp = self.kw_in_joyhub_c_product_payment_recommend_page_get(**kwargs) + obj_log.info(f"获得支付页产品推荐分页响应: {resp}") + return resp diff --git a/dulizhan/library/BusinessKw/JoyHubC/UserManage.py b/dulizhan/library/BusinessKw/JoyHubC/UserManage.py new file mode 100644 index 0000000..1f66258 --- /dev/null +++ b/dulizhan/library/BusinessKw/JoyHubC/UserManage.py @@ -0,0 +1,27 @@ +# -*- coding:utf-8 -*- +""" +JoyHub C端用户业务关键字层 +""" +import allure +from dulizhan.library.BusinessKw.JoyHubC.LoginManage import JoyHubCLoginManage +from base_framework.public_tools import log + +obj_log = log.get_logger() + + +class JoyHubCUserManage(JoyHubCLoginManage): + """JoyHub C端用户业务关键字类""" + + def __init__(self): + super().__init__() + + @allure.step("查询当前用户积分") + def kw_joyhub_c_client_get_point_get(self): + """ + 查询当前用户积分业务关键字 + :return: 响应结果 + """ + obj_log.info("查询当前用户积分") + resp = self.kw_in_joyhub_c_client_get_point_get() + obj_log.info(f"查询当前用户积分响应: {resp}") + return resp diff --git a/dulizhan/library/BusinessKw/JoyHubC/__init__.py b/dulizhan/library/BusinessKw/JoyHubC/__init__.py new file mode 100644 index 0000000..380474e --- /dev/null +++ b/dulizhan/library/BusinessKw/JoyHubC/__init__.py @@ -0,0 +1 @@ +# -*- coding:utf-8 -*- diff --git a/dulizhan/library/Dlizhan_interface.py b/dulizhan/library/Dlizhan_interface.py index 98aa005..cf5b4bf 100644 --- a/dulizhan/library/Dlizhan_interface.py +++ b/dulizhan/library/Dlizhan_interface.py @@ -14,6 +14,10 @@ from base_framework.public_tools import utils from base_framework.public_tools.pgsqlhelper import PgSqlHelper import requests import json +import re +import imaplib +import email as email_parser +from email.header import decode_header obj_log = log.get_logger() obj_runner = Runner() @@ -25,7 +29,11 @@ class DlzhanInterface: self.domain_url = eureka.get_url_from_config() self.pg_db = PgSqlHelper() self.joyhub_domain = "https://joyhub-website-manager-api-test.best-envision.com" + self.joyhub_c_domain = "https://joyhub-website-frontend-test.best-envision.com" + self.joyhub_c_frontend_url = "https://joyhub-website-frontend-test.best-envision.com/" + self.joyhub_c_session = requests.session() self.token = None + self.joyhub_c_token = None def _get_joyhub_headers(self): headers = { @@ -39,6 +47,47 @@ class DlzhanInterface: def set_joyhub_token(self, token): self.token = token + def set_joyhub_c_token(self, token): + self.joyhub_c_token = token + + def _get_joyhub_c_headers(self): + headers = { + 'accept': '*/*', + 'Content-Type': 'application/json', + 'jh-appchannel': '5', + 'origin': self.joyhub_c_domain, + 'referer': self.joyhub_c_frontend_url, + 'tenant-id': '126' + } + if self.joyhub_c_token: + headers['Authorization'] = 'Bearer ' + self.joyhub_c_token + return headers + + def _joyhub_c_request(self, method, path, is_check='', note='', return_json=True, **kwargs): + url = path if path.startswith('http') else "{}{}".format(self.joyhub_c_domain, path) + headers = self._get_joyhub_c_headers() + obj_log.info("=========== {} ===========".format(note or path)) + + req_params = {} + for key, value in kwargs.items(): + if value is not None and value != '': + req_params[key] = value + + req_map = { + 'GET': lambda: self.joyhub_c_session.get(url, headers=headers, params=req_params, verify=False), + 'POST': lambda: self.joyhub_c_session.post(url, headers=headers, json=req_params, verify=False), + 'PUT': lambda: self.joyhub_c_session.put(url, headers=headers, json=req_params, verify=False), + 'DELETE': lambda: self.joyhub_c_session.delete(url, headers=headers, verify=False) + } + + resp = req_map.get(method.upper(), lambda: None)() + self._check_resp(is_check, resp) + + if return_json: + return resp.json() + else: + return resp + def _joyhub_request(self, method, path, is_check='', note='', return_json=True, **kwargs): url = "{}{}".format(self.joyhub_domain, path) headers = self._get_joyhub_headers() @@ -684,12 +733,165 @@ class DlzhanInterface: def kw_in_joyhub_product_payment_recommend_page_get(self, is_check='', **kwargs): return self._joyhub_request('GET', '/admin-api/jh/product-payment-recommend/page', is_check, '获得支付页产品推荐分页', **kwargs) + # ============ C端-登录公共接口 ============ + def kw_in_joyhub_c_login_post(self, path, is_check='', **kwargs): + return self._joyhub_c_request('POST', path, is_check, 'JoyHub C端登录', **kwargs) + + def kw_in_joyhub_c_get_email_code(self, email, code_pattern=r'\d{4,8}'): + auth_code = os.environ.get('JOYHUB_C_EMAIL_AUTH_CODE') or os.environ.get('NETEASE_163_AUTH_CODE') + if not auth_code: + raise Exception("网易163邮箱授权码不能为空,请先设置环境变量 JOYHUB_C_EMAIL_AUTH_CODE") + + obj_log.info("开始连接网易163邮箱获取验证码 - email: {}".format(email)) + mail = imaplib.IMAP4_SSL('imap.163.com', 993) + try: + mail.login(email, auth_code) + status, _ = mail.select('INBOX') + if status != 'OK': + raise Exception("邮箱 {} 无法选择收件箱".format(email)) + status, data = mail.search(None, 'ALL') + if status != 'OK' or not data or not data[0]: + raise Exception("邮箱 {} 未查询到邮件".format(email)) + + email_ids = data[0].split() + for email_id in reversed(email_ids[-20:]): + status, msg_data = mail.fetch(email_id, '(RFC822)') + if status != 'OK' or not msg_data: + continue + + msg = email_parser.message_from_bytes(msg_data[0][1]) + subject = self._decode_email_header(msg.get('Subject', '')) + content = self._get_email_content(msg) + match = re.search(code_pattern, '{}\n{}'.format(subject, content or '')) + if match: + obj_log.info("网易163邮箱验证码获取成功") + return match.group(0) + + raise Exception("邮箱 {} 最近20封邮件中未匹配到验证码".format(email)) + finally: + try: + mail.logout() + except Exception: + pass + + def _decode_email_header(self, value): + decoded_parts = decode_header(value) + result = '' + for part, charset in decoded_parts: + if isinstance(part, bytes): + result += part.decode(charset or 'utf-8', errors='ignore') + else: + result += part + return result + + def _get_email_content(self, msg): + contents = [] + if msg.is_multipart(): + for part in msg.walk(): + content_type = part.get_content_type() + content_disposition = str(part.get('Content-Disposition')) + if content_type in ('text/plain', 'text/html') and 'attachment' not in content_disposition: + payload = part.get_payload(decode=True) + if payload: + charset = part.get_content_charset() or 'utf-8' + contents.append(payload.decode(charset, errors='ignore')) + else: + payload = msg.get_payload(decode=True) + if payload: + charset = msg.get_content_charset() or 'utf-8' + contents.append(payload.decode(charset, errors='ignore')) + return '\n'.join(contents) + + # ============ C端-用户接口 ============ + def kw_in_joyhub_c_client_get_point_get(self, is_check=''): + return self._joyhub_c_request('GET', '/web-api/jh/client/get/point', is_check, '查询当前用户积分') + + # ============ C端-Banner信息接口 ============ + def kw_in_joyhub_c_banner_get_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/banner/get', is_check, '获得Banner管理', **kwargs) + + def kw_in_joyhub_c_banner_page_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/banner/page', is_check, '获得Banner管理分页', **kwargs) + + # ============ C端-blog信息接口 ============ + def kw_in_joyhub_c_blog_get_detail_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/blog/get-detail', is_check, '获得blog详情', **kwargs) + + def kw_in_joyhub_c_blog_get_next_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/blog/get-next', is_check, '获得blog下一条', **kwargs) + + def kw_in_joyhub_c_blog_page_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/blog/page', is_check, '获得blog管理分页', **kwargs) + + # ============ C端-blog分类接口 ============ + def kw_in_joyhub_c_blog_cate_list_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/blog-cate/list', is_check, '获得blog分类列表', **kwargs) + + # ============ C端-FAQ接口 ============ + def kw_in_joyhub_c_faq_cate_list_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/faq/cate-list', is_check, '获得FAQ分类树', **kwargs) + + def kw_in_joyhub_c_faq_list_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/faq/list', is_check, '获得FAQ列表', **kwargs) + + # ============ C端-news分类接口 ============ + def kw_in_joyhub_c_news_cate_list_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/news-cate/list', is_check, '获得news分类列表', **kwargs) + + # ============ C端-news管理接口 ============ + def kw_in_joyhub_c_news_get_detail_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/news/get-detail', is_check, '获得news详情', **kwargs) + + def kw_in_joyhub_c_news_get_next_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/news/get-next', is_check, '获得news下一条', **kwargs) + + def kw_in_joyhub_c_news_page_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/news/page', is_check, '获得news管理分页', **kwargs) + + # ============ C端-APP版本接口 ============ + def kw_in_joyhub_c_web_appversion_page_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/web/appversion/page', is_check, '获取APP版本列表', **kwargs) + + # ============ C端-产品接口 ============ + def kw_in_joyhub_c_product_get_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/product/get', is_check, '产品详情', **kwargs) + + def kw_in_joyhub_c_product_page_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/product/page', is_check, '获得产品分页', **kwargs) + # ============ C端-支付页产品推荐接口 ============ - def kw_in_joyhub_web_product_payment_recommend_page_get(self, is_check='', **kwargs): - return self._joyhub_request('GET', '/web-api/jh/product-payment-recommend/page', is_check, '获得支付页产品推荐分页', **kwargs) + def kw_in_joyhub_c_product_payment_recommend_page_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/product-payment-recommend/page', is_check, '获得支付页产品推荐分页', **kwargs) + + # ============ C端-合作联系接口 ============ + def kw_in_joyhub_c_cooperation_create_post(self, is_check='', **kwargs): + return self._joyhub_c_request('POST', '/web-api/jh/cooperation/create', is_check, '提交合作联系信息', **kwargs) + + # ============ C端-二维码访问统计接口 ============ + def kw_in_joyhub_c_download_qrcode_get_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/download-qrcode/get', is_check, '获取二维码信息', **kwargs) + + def kw_in_joyhub_c_download_qrcode_increment_post(self, is_check='', **kwargs): + return self._joyhub_c_request('POST', '/web-api/jh/download-qrcode/increment', is_check, '增加二维码访问/点击次数', **kwargs) + + # ============ C端-FAQ联系我们接口 ============ + def kw_in_joyhub_c_faq_contact_us_create_post(self, is_check='', **kwargs): + return self._joyhub_c_request('POST', '/web-api/jh/faq-contact-us/create', is_check, '提交FAQ联系信息', **kwargs) + + # ============ C端-点赞记录接口 ============ + def kw_in_joyhub_c_like_info_create_post(self, is_check='', **kwargs): + return self._joyhub_c_request('POST', '/web-api/jh/like-info/create', is_check, '创建点赞记录', **kwargs) + + def kw_in_joyhub_c_like_info_delete_post(self, is_check='', **kwargs): + return self._joyhub_c_request('POST', '/web-api/jh/like-info/delete', is_check, '取消点赞', **kwargs) + + def kw_in_joyhub_c_like_info_get_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/like-info/get', is_check, '获得点赞记录', **kwargs) + + def kw_in_joyhub_c_like_info_page_get(self, is_check='', **kwargs): + return self._joyhub_c_request('GET', '/web-api/jh/like-info/page', is_check, '获得点赞记录分页', **kwargs) if __name__ == '__main__': test = DlzhanInterface() - a = test.kw_in_zhyy_purchase_todo_get(user="purchase") - print(a) + print() diff --git a/dulizhan/test_case/Resource/AdapterKws/hh-qa.robot b/dulizhan/test_case/Resource/AdapterKws/hh-qa.robot index 863eded..8d98248 100644 --- a/dulizhan/test_case/Resource/AdapterKws/hh-qa.robot +++ b/dulizhan/test_case/Resource/AdapterKws/hh-qa.robot @@ -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端测试地址 + + diff --git a/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_AppVersion.py b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_AppVersion.py new file mode 100644 index 0000000..d366bd0 --- /dev/null +++ b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_AppVersion.py @@ -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版本列表接口验证通过") diff --git a/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Banner.py b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Banner.py new file mode 100644 index 0000000..a2f2299 --- /dev/null +++ b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Banner.py @@ -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管理接口验证通过") diff --git a/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Blog.py b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Blog.py new file mode 100644 index 0000000..c0bb105 --- /dev/null +++ b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Blog.py @@ -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下一条接口验证通过") diff --git a/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_BlogCate.py b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_BlogCate.py new file mode 100644 index 0000000..fc665f2 --- /dev/null +++ b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_BlogCate.py @@ -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分类列表接口验证通过") diff --git a/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Cooperation.py b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Cooperation.py new file mode 100644 index 0000000..5ec68ed --- /dev/null +++ b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Cooperation.py @@ -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端提交合作联系信息接口验证通过") diff --git a/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_DownloadQrcode.py b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_DownloadQrcode.py new file mode 100644 index 0000000..a102b03 --- /dev/null +++ b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_DownloadQrcode.py @@ -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端增加二维码访问/点击次数接口验证通过") diff --git a/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Faq.py b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Faq.py new file mode 100644 index 0000000..c99bee8 --- /dev/null +++ b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Faq.py @@ -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列表接口验证通过") diff --git a/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_FaqContactUs.py b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_FaqContactUs.py new file mode 100644 index 0000000..6a9ad00 --- /dev/null +++ b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_FaqContactUs.py @@ -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联系信息接口验证通过") diff --git a/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_LikeInfo.py b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_LikeInfo.py new file mode 100644 index 0000000..b2361f8 --- /dev/null +++ b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_LikeInfo.py @@ -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端取消点赞接口验证通过") diff --git a/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_News.py b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_News.py new file mode 100644 index 0000000..72c1bba --- /dev/null +++ b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_News.py @@ -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下一条接口验证通过") diff --git a/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_NewsCate.py b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_NewsCate.py new file mode 100644 index 0000000..a09e0e3 --- /dev/null +++ b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_NewsCate.py @@ -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分类列表接口验证通过") diff --git a/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Product.py b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Product.py new file mode 100644 index 0000000..bf8ca7f --- /dev/null +++ b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_Product.py @@ -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端产品详情接口验证通过") diff --git a/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_ProductPaymentRecommend.py b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_ProductPaymentRecommend.py new file mode 100644 index 0000000..9a7c00f --- /dev/null +++ b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_ProductPaymentRecommend.py @@ -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端获得支付页产品推荐分页接口验证通过") diff --git a/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_UserPoint.py b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_UserPoint.py new file mode 100644 index 0000000..daf2c83 --- /dev/null +++ b/dulizhan/test_case/TestCase/接口/JoyHubC/JoyhubC_UserPoint.py @@ -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("查询当前用户积分接口验证通过") diff --git a/dulizhan/test_case/TestCase/接口/JoyHubC/__init__.py b/dulizhan/test_case/TestCase/接口/JoyHubC/__init__.py new file mode 100644 index 0000000..e69de29