예제 #1
0
    def test_query_order(self):
        """查询订单"""
        # 订单id
        order_id = 115
        # 响应对象
        res = ApiFactory.get_order_api().query_order_api(order_id)
        logging.info("请求地址:{}".format(res.url))
        logging.info("响应数据:{}".format(res.json()))
        # 断言 状态码
        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") == "18888888888"
예제 #2
0
    def test_order_api(self):
        """创建订单"""
        # 商品id
        product_id = 7
        # 购买数量
        count = 3
        # 响应对象
        res = ApiFactory.get_order_api().create_order_api(product_id, count)
        logging.info("请求地址:{}".format(res.url))
        logging.info("响应数据:{}".format(res.json()))
        # 断言 状态码
        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
예제 #3
0
    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"]
        ]
예제 #4
0
from Api.api import ApiFactory

# 调用轮播图api
# print("轮播图:{}".format(ApiFactory.get_home_api().banner_api().json()))

# 调用主题
# print("主题:{}".format(ApiFactory.get_home_api().theme_api().json()))
# 调用最新商品
# 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()))
# 调用商品信息
# print("商品信息:{}".format(ApiFactory.get_product_api().product_detail_api().json()))

# 调用获取token方法
# 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(114).json()))