# -*- 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分类列表接口验证通过")