def test_banner(self, banner_code, banner_id, banner_name, banner_length): """ :param banner_code: 状态码 :param banner_id: id :param banner_name: name :param banner_length: items长度大于0 :return: """ print("banner_code:{}, banner_id:{}, banner_name:{}, banner_length:{}". format(banner_code, banner_id, banner_name, banner_length)) # 请求 res = ApiFactory.home_api().banner() # 断言 -状态码 auto(self, res.status_code, banner_code) # 断言 id auto(self, res.json().get("id"), banner_id) # 断言 name auto(self, res.json().get("name"), banner_name) # 断言items长度大于0 auto(self, len(res.json().get("items")), banner_length, tag="more") # 断言图片utl不为空 auto(self, len(res.json().get("items")[0].get("img").get("url")), banner_length, tag="more")
def test_theme(self, theme_code, theme_ids, theme_length_url, theme_name): """ :param theme_code: 状态码 :param theme_ids: id=1 id=2 id =3 :param theme_length_url: 长度 -url :param theme_name: 专题名字 :return: """ print( "theme_code:{}, theme_ids:{}, theme_length_url:{}, theme_name:{}". format(theme_code, theme_ids, theme_length_url, theme_name)) # 请求 res = ApiFactory.home_api().theme() # 断言 -状态码 auto(self, res.status_code, theme_code) # 断言 -id=1 id=2 id =3 for i in theme_ids: auto(self, i, res.text, tag="in") # 断言 长度 auto(self, len(res.json()), theme_length_url, tag="more") # 断言 -name auto(self, res.json()[0].get("name"), theme_name) # 断言 -url auto(self, len(res.json()[0].get("topic_img").get("url")), theme_length_url, tag="more")
def test_new_product(self, new_code, new_length, new_keys): """ :param new_code: 状态码 :param new_length: 长度 :param new_keys: 关键字段 :return: """ print("new_code:{}, new_length:{}, new_keys:{}".format( new_code, new_length, new_keys)) # 请求 res = ApiFactory.home_api().new_product() # 断言 -状态码 auto(self, res.status_code, new_code) # 断言 - 长度 auto(self, len(res.json()), new_length, tag="more") # 断言 -关键字段 for i in new_keys: auto(self, i, res.text, tag="in")
from Api.apiFactory import ApiFactory # 首页 -轮播图 print("首页:{}".format(ApiFactory.home_api().banner().json())) # 首页 -专题栏 print("专题栏:{}".format(ApiFactory.home_api().theme().json())) # 首页 -新品 print("新品:{}".format(ApiFactory.home_api().new_product().json()))