Esempio n. 1
0
 def test_product_info(self):
     res = ApiFactory.get_product_api().product_info_api()
     logging.info('请求地址:{}'.format(res.url))
     logging.info('响应数据:{}'.format(res.json()))
     utils.common_assert_code(res)
     assert res.json().get('id') == 2
     assert res.json().get('price') == '0.01'
Esempio n. 2
0
 def test_token_verify_api(self):
     res = ApiFactory.get_user_api().token_verify_api()
     # 打印请求地址 打印请求参数 打印请求响应数据
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     utils.common_assert_code(res)
     assert res.json().get("isValid") is True
Esempio n. 3
0
 def test_product_classify_api(self):
     res = ApiFactory.get_product_api().product_classify_api()
     logging.info('请求地址:{}'.format(res.url))
     logging.info('响应数据:{}'.format(res.json()))
     utils.common_assert_code(res)
     assert len(res.json()) > 0
     assert 'id' in res.text and 'name' in res.text
Esempio n. 4
0
 def test_verify_token(self):
     """响应"""
     res = ApiFactory.get_user_api().verify_token_api()
     logging.info('请求地址:{}'.format(res.url))
     logging.info('响应数据:{}'.format(res.json()))
     utils.common_assert_code(res)
     assert res.json().get('isValid') is True
Esempio n. 5
0
 def test_query_order(self, 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)
     assert res.json().get("id") == order_id
     assert res.json().get("snap_address").get("name") == "刘锦"
Esempio n. 6
0
 def test_classify_product_api(self):
     res = ApiFactory.get_product_api().clssify_product_api()
     logging.info('请求地址:{}'.format(res.url))
     logging.info('响应数据:{}'.format(res.json()))
     utils.common_assert_code(res)
     assert len(res.json()) > 0
     assert False not in [i in res.text for i in ['id', 'name', 'price']]
Esempio n. 7
0
 def test_create_order(self, 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)
     assert len(res.json().get("order_no")) > 0 and len(
         res.json().get("order_id")) > 0
Esempio n. 8
0
    def test_verify_token_api(self):
        """验证token"""
        res = Apifactory.get_user_api().verify_token_api()
        logging.info("请求地址{}".format(res.url))
        logging.info("响应数据{}".format(res.json()))
        utils.common_assert_code(res)

        assert res.json().get("isValid") is True
Esempio n. 9
0
 def test_get_token(self):
     res = ApiFactory.get_user_api().get_token_api()
     logging.info('请求地址:{}'.format(res.url))
     logging.info('响应数据:{}'.format(res.json()))
     utils.common_assert_code(res)
     assert len(res.json().get('token')) > 0
     app.headers['token'] = res.json().get('token')
     print('app.headers:{}'.format(app.headers))
Esempio n. 10
0
 def test_get_token(self):
     res = ApiFactory.get_user_api().get_token_api()
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     utils.common_assert_code(res)
     assert len(res.json().get("token")) > 0
     app.headers["token"] = res.json().get("token")
     print("app.headers:{}".format(app.headers))
Esempio n. 11
0
 def test_verify_token(self):
     """验证token"""
     # 响应对象
     res = ApiFactory.get_user_api().verify_token_api()
     # 断言状态码
     utils.common_assert_code(res)
     # 断言有效
     assert res.json().get("isValid") is True
Esempio n. 12
0
 def test_product_classify(self):
     res = ApiFactory.product_api().product_classify_api()
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     # 断言响应状态码
     utils.common_assert_code(res)
     assert len(res.json()) > 0
     assert "果味" in res.text
Esempio n. 13
0
 def test_user_address(self):
     res = ApiFactory.user_api().get_address_api()
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     utils.common_assert_code(res)
     assert False not in [
         i in res.text for i in ["SSR", "16666666666", "上海市", "浦东新区"]
     ]
Esempio n. 14
0
 def test_token_verify(self):
     """验证token"""
     res = ApiFactory.get_user_api().token_verify_api()
     # 打印 请求地址,响应数据
     logging.info('请求地址:{}'.format(res.url))
     logging.info('响应数据:{}'.format(res.json()))
     # 断言
     utils.common_assert_code(res)
     assert res.json().get('isValid') is True
Esempio n. 15
0
 def test_create_order(self):
     product_id = 12
     count = 7
     res = ApiFactory.order_api().create_order_api(product_id, count)
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     utils.common_assert_code(res)
     assert res.json().get("pass") is True
     assert False not in [i in res.text for i in ["order_no", "order_id", "create_time", "pass"]]
Esempio n. 16
0
 def test_user_addr_api(self):
     res = Apifactory.get_user_api().user_addr_api()
     logging.info("请求地址{}".format(res.url))
     logging.info("响应数据{}".format(res.json()))
     utils.common_assert_code(res)
     assert False not in [
         i in res.text
         for i in ["司马狗剩", "13866666666", "上海市", "浦东新区", "110号"]
     ]
Esempio n. 17
0
 def test_verify_token(self):
     res = ApiFactory.get_user_api().token_verify_api()
     # 打印 请求地址 请求参数 请求响应数据
     logging.info(f"请求地址:{res.url}")
     logging.info(f"请求响应数据:{res.json()}")
     # 断言状态码
     utils.common_assert_code(res)
     # 断言有效
     assert res.json().get("isValid")
Esempio n. 18
0
    def test_classify_product(self):
        res = ApiFactory.product_api().classify_product_api()
        logging.info("请求地址:{}".format(res.url))
        logging.info("响应数据:{}".format(res.json()))
        # 断言响应状态码
        utils.common_assert_code(res)

        assert len(res.json()) > 0
        assert False not in [i in res.text for i in ["name", "main_img_url", "price", "img_id"]]
Esempio n. 19
0
 def test_product_datail_api(self):
     """商品信息"""
     res = Apifactory.get_product_api().product_datail_api()
     logging.info("请求地址{}".format(res.url))
     logging.info("响应数据{}".format(res.json()))
     utils.common_assert_code(res)
     assert res.json().get("id") == 2
     assert res.json().get("price") == '0.01'
     assert res.json().get("name") == '梨花带雨 3个'
Esempio n. 20
0
 def test_token_verify_api(self):
     res = ApiFactory.get_user_api().token_verify_api()
     # 打印请求地址,打印请求参数 打印响应数据
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     # 断言响应状态码
     utils.common_assert_code(res, 200)
     # 断言值为true
     assert res.json().get('isValid') is True
Esempio n. 21
0
 def test_theme_api(self):
     """专题栏"""
     # 请求返回对象
     res = ApiFactory.get_home_api().theme_api()
     # 断言状态码
     utils.common_assert_code(res)
     # 断言三个id = 1 2 3
     assert 'id":1' in res.text and 'id":2' in res.text and 'id":3' in res.text
     # 断言关键字段  name description topic_img head_img
     assert False not in [i in res.text for i in ["name", "description", "topic_img", "head_img"]]
Esempio n. 22
0
 def test_user_address(self):
     """获取地址信息"""
     res = ApiFactory.get_user_api().user_address_api()
     # 打印 请求地址,响应数据
     logging.info('请求地址:{}'.format(res.url))
     logging.info('响应数据:{}'.format(res.json()))
     # 断言
     utils.common_assert_code(res)
     # 断言信息
     assert False not in [i in res.text for i in ['里斯', '上海市', '123号']]
Esempio n. 23
0
    def test_product_detail(self):
        res = ApiFactory.product_api().product_detail_api()
        logging.info("请求地址:{}".format(res.url))
        logging.info("响应数据:{}".format(res.json()))
        # 断言响应状态码
        utils.common_assert_code(res)

        assert res.json().get("id") == 2
        assert res.json().get("price") == "0.01"
        assert False not in [i in res.text for i in ["id", "name", "price", "stock"]]
Esempio n. 24
0
    def test_product_classify_api(self):
        """商品分类"""
        res = Apifactory.get_product_api().product_classify_api()
        logging.info("请求地址{}".format(res.url))
        logging.info("响应数据{}".format(res.json()))
        utils.common_assert_code(res)

        assert len(res.json()) > 0

        assert "id" in res.text and "name" in res.text and "topic_img_id" in res.text
Esempio n. 25
0
 def test_verify_token(self):
     """验证token"""
     res = ApiFactory.get_user_api().verify_token_api()
     # 打印请求地址 请求参数 请求响应数据
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     # 断言状态码
     utils.common_assert_code(res)
     # 断言有效
     assert res.json().get("isValid") is True
Esempio n. 26
0
 def test_recent_product_api(self):
     """最近新品"""
     # 请求返回数据
     res = ApiFactory.get_home_api().recent_product_api()
     # 断言状态码
     utils.common_assert_code(res)
     # 断言商品数量大于0
     assert len(res.json()) > 0
     # 断言关键字段
     assert "id" in res.text and "name" in res.text and "price" in res.text
Esempio n. 27
0
    def test_home_api(self):
        """轮播图"""
        res = Apifactory.get_home_api().banner_api()
        logging.info("请求地址{}".format(res.url))
        logging.info("响应数据{}".format(res.json()))
        # 断言状态码
        utils.common_assert_code(res)

        # 断言items列表长度大于0
        assert len(res.json().get("items")) > 0
Esempio n. 28
0
 def test_product_classify_api(self):
     """商品分类"""
     # 获取响应对象
     res = ApiFactory.get_product_api().product_calssify_api()
     # 断言状态码
     utils.common_assert_code(res)
     # 断言长度
     assert len(res.json()) > 0
     # 断言关键字段
     assert "id" in res.text and "name" in res.text and "topic_img_id" in res.text
Esempio n. 29
0
 def test_verify_api(self):
     """验证token"""
     # 响应对象
     res = ApiFactory.user_api().get_verify_api()
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     # 断言状态码
     utils.common_assert_code(res)
     # 断言有效
     assert res.json().get("isValid") is True
Esempio n. 30
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
     assert len(res.json()) > 0
     assert False not in [
         i in res.text for i in ["id", "order_no", "total_price"]
     ]