def test_create_order(self): """创建订单""" res = ApiFactory.get_order_api().create_order_api(7, 3) # 打印 请求地址,响应数据 logging.info('请求地址:{}'.format(res.url)) logging.info('响应数据:{}'.format(res.json())) # 断言 状态码 utils.common_assert_code(res) assert len(res.json().get('order_no')) > 0 and len( res.json().get('order_id')) > 0 assert res.json().get('pass') is True
def test_order_api(self): res = ApiFactory.get_order_api().get_order_api() logging.info('请求地址:{}'.format(res.url)) logging.info('响应数据:{}'.format(res.json())) # 断言响应状态码 utils.comman_assert_method(res) # 断言当前页面为第一页 assert res.json().get('current_page') == 1 # 断言订单数据大于0 assert len(res.json()) > 0 # 断言关键字段 assert [i in res.text for i in ['id', 'order_no', 'total_price']]
def test_check_order_api(self): res = ApiFactory.get_order_api().check_order_api(121) logging.info('请求地址:{}'.format(res.url)) logging.info('响应数据:{}'.format(res.json())) # 断言响应状态码 utils.comman_assert_method(res) # 断言订单id assert res.json().get("id") == 121 # 断言地址 用户名 手机号 assert res.json().get("snap_address").get("name") == "小笼包" assert res.json().get("snap_address").get("mobile") == "15139715195"
def test_create_order_api(self): res = ApiFactory.get_order_api().create_order_api(7, 3) logging.info('请求地址:{}'.format(res.url)) logging.info('响应数据:{}'.format(res.json())) # 断言响应状态码 utils.comman_assert_method(res) # 订单编号 和 订单id 不为空 assert len(res.json().get("order_no")) > 0 and len( res.json().get("order_id")) > 0 # 断言订单是否通过 assert res.json().get("pass") is True
def test_order_list(self): """查看订单列表""" res = ApiFactory.get_order_api().order_list_api() # 打印 请求地址,响应数据 logging.info('请求地址:{}'.format(res.url)) logging.info('响应数据:{}'.format(res.json())) # 断言 状态码 utils.common_assert_code(res) # 断言是第一页 assert res.json().get('current_page') == 1 # 断言数据大于0 assert len(res.json()) > 0
def test_query_order(self): """查看订单详情""" res = ApiFactory.get_order_api().query_order_api(105) # 打印 请求地址,响应数据 logging.info('请求地址:{}'.format(res.url)) logging.info('响应数据:{}'.format(res.json())) # 断言 状态码 utils.common_assert_code(res) # 断言 订单id assert res.json().get('id') == 105 assert res.json().get('snap_address').get('name') == '里斯' assert res.json().get('snap_address').get('mobile') == '15878789898'
def test_query_order(self): """查询订单""" # 订单id order_id = 115 # 响应对象 res = ApiFactory.get_order_api().query_order_api(order_id) # 断言 状态码 utils.common_assert_code(res) # 断言订单id assert res.json().get("id") == 115 # 断言地址 用户名 手机号 assert res.json().get("snap_address").get("name") == "没戏" assert res.json().get("snap_address").get("mobile") == "15811112222"
def test_order_api(self): """创建订单""" # 商品id product_id = 7 # 购买数量 count = 3 # 响应对象 res = ApiFactory.get_order_api().create_order_api(product_id, count) # 断言 状态码 utils.common_assert_code(res) # 订单编号 和 订单id 不为空 assert len(res.json().get("order_no")) > 0 and len( res.json().get("order_id")) > 0 # 断言订单是否通过 assert res.json().get("pass") is True
def test_order_list(self): """订单列表""" # 响应对象 res = ApiFactory.get_order_api().order_list_api() # 打印请求地址,响应数据 logging.info("请求地址:{}".format(res.url)) logging.info("响应数据:{}".format(res.json())) # 断言 状态码 utils.common_assert_code(res) # 断言页面是否是第一个 assert res.json().get("current_page") == 1 # 断言 订单数据大于0 根据用户数据决定 assert len(res.json()) > 0 # 断言关键字段 assert False not in [ i in res.text for i in ["id", "order_no", "total_price"] ]
from api.apiFactory import ApiFactory # # 调用轮播图api # print("轮播图:{}".format(ApiFactory.get_home_api().banner_api().json())) # # # 调用主题api # print("主题:{}".format(ApiFactory.get_home_api().theme_api().json())) # # # 调用最近新品api # print("最近新品:{}".format(ApiFactory.get_home_api().recent_api().json())) # 调用商品分类 # print("分类:{}".format(ApiFactory.get_product_api().product_classify_api().json())) # # 调用分类下商品 # print("分类下商品:{}".format(ApiFactory.get_product_api().classify_product_api().json())) # # 调用商品信息3 # print("商品信息:{}".format(ApiFactory.get_product_api().product_detail_api().json())) # print("返回值:{}".format(ApiFactory.get_user_api().get_token_api().json())) print("订单列表:{}".format(ApiFactory.get_order_api().order_list_api().json())) print("创建订单:{}".format(ApiFactory.get_order_api().create_order_api(12, 7).json())) print("查看订单:{}".format(ApiFactory.get_order_api().query_order_api(120).json()))