예제 #1
0
 def test_classify_product(self):
     """分类下商品"""
     res = ApiFactory.get_product_api().classify_product_api(6)
     # 打印 请求参数、请求地址、请求响应数据
     logging.info('请求地址:{}'.format(res.url))
     logging.info('请求响应:{}'.format(res.json()))
     # 断言响应状态码
     utils.common_assert(res)
     # 断言商品分类大于0
     assert len(res.json()) > 0
     # 断言存在 id name description url
     # assert False not in [i in res.text for i in ['id', 'name', 'price', 'stock']]
     assert True in [
         i in res.text for i in ['id', 'name', 'price', 'stock']
     ]
예제 #2
0
 def test_classify_product_api(self):
     """分类下商品"""
     # 获取响应对象
     res = ApiFactory.get_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 ["id", "name", "price", "stock"]
     ]
예제 #3
0
 def test_product_detail(self):
     """商品信息"""
     # 获取响应对象
     res = ApiFactory.get_product_api().product_detail_api()
     # 打印请求地址 打印请求参数 打印请求响应数据
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     # 断言状态码
     utils.common_assert_code(res)
     # 断言id
     assert res.json().get("id") == 2
     # 断言price
     assert res.json().get("price") == "0.01"
     # 断言name
     assert res.json().get("name") == "梨花带雨 3个"
예제 #4
0
파일: testproduct.py 프로젝트: ww001m/wx
    def test_product_detail(self):
        # 获取响应对象
        res = ApiFactory.get_product_api().product_detail_api(2)
        # 打印请求地址 请求参数 请求响应数据
        logging.info('请求地址:{}'.format(res.url))
        logging.info('响应数据:{}'.format(res.json()))
        # 断言状态码
        utils.common_assert_code(res)

        # 断言id
        assert res.json().get('id') == 2
        # 断言price
        assert res.json().get('price') == '0.01'
        # 断言name
        assert res.json().get('name') == '梨花带雨 3个'
예제 #5
0
파일: testproduct.py 프로젝트: ww001m/wx
    def test_classify_product_api(self):
        # 获取响应对象
        res = ApiFactory.get_product_api().classify_product_api()
        # 打印请求地址 请求参数 请求响应数据
        logging.info('请求地址:{}'.format(res.url))
        logging.info('响应数据:{}'.format(res.json()))
        # 断言状态码
        utils.common_assert_code(res)

        # 断言新品数量大于0
        assert len(res.json()) > 0
        # 断言关键字段
        assert False not in [
            i in res.text for i in ['id', 'name', 'price', 'stock']
        ]
예제 #6
0
    def test_theme_api(self):
        res = ApiFactory.get_home_api().theme_api()
        # 打印请求地址 打印请求参数 打印请求响应数据
        logging.info("请求地址:{}".format(res.url))
        logging.info("响应数据:{}".format(res.json()))
        # 断言响应状态码
        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"]
        ]
예제 #7
0
 def test_recent_api(self):
     """最近新品"""
     # 请求返回数据
     res = ApiFactory.get_home_api().recent_product_api()
     # 打印请求地址  打印请求参数 打印请求响应数据
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     # 断言状态码
     assert res.status_code == 200
     # 断言新品数量大于0
     assert len(res.json())
     # 断言关键字段
     assert False not in [
         i in res.text for i in ["id", "name", "price", "stock"]
     ]
예제 #8
0
    def test_home_api(self):
        """轮播图"""
        # 请求返回数据
        res = ApiFactory.get_home_api().banner_api()
        # 打印请求地址,请求参数,请求响应数据
        logging.info(f"请求地址:{res.url}")
        logging.info(f"请求地址:{res.json()}")

        # 断言状态码
        utils.common_assert_code(res)

        # 断言id和name
        assert res.json().get("id") == 1 and res.json().get("name") == "首页置顶"
        # 断言items列表长度大于0
        assert len(res.json().get("items")) > 0
예제 #9
0
 def test_theme_api(self):
     """专题栏"""
     res = ApiFactory.get_home_api().theme_api()
     # 打印请求地址 请求参数 请求响应数据
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     # 断言状态码
     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
     # 断言关键字段
     assert False not in [
         i in res.text
         for i in ["name", "description", "topic_img", "head_img"]
     ]
예제 #10
0
 def test_theme_api(self):
     """专题栏"""
     # 请求数据
     respond = ApiFactory.get_home_api().theme_api()
     logging.info('请求地址:{}'.format(respond.url))
     logging.info('响应数据:{}'.format(respond.json()))
     # 断言状态码
     utils.common_assert_code(respond)
     # 断言三个 id = 1, 2, 3
     assert 'id":1' in respond.text and 'id":2' in respond.text and 'id":3' in respond.text
     # 断言关键字段 name description head_img topic_img
     assert False not in [
         i in respond.text
         for i in ['name', 'description', 'head_img', 'topic_img']
     ]
예제 #11
0
    def test_recent_product_api(self):
        """最近新品"""
        # 请求返回数据
        res = ApiFactory.get_home_api().recent_product_api()
        # 打印请求地址,请求参数,请求响应数据
        logging.info(f"请求地址:{res.url}")
        logging.info(f"请求地址:{res.json()}")

        # 断言状态码
        utils.common_assert_code(res)
        # 断言3个id
        assert '"id":1' in res.text and '"id":2' in res.text and '"id":3' in res.text
        # 断言新品数量大于0
        assert len(res.json()) > 0
        # 断言关键字段name,description,topic_img,head_img
        assert "id" in res.text and "name" in res.text and "price" in res.text
예제 #12
0
 def test_product_detail(self):
     """商品信息"""
     res = ApiFactory.get_product_api().product_detail_api(20)
     # 打印 请求参数、请求地址、请求响应数据
     logging.info('请求地址:{}'.format(res.url))
     logging.info('请求响应:{}'.format(res.json()))
     # 断言响应状态码
     utils.common_assert(res)
     # 断言商品分类大于0
     assert len(res.json()) > 0
     # 断言 id
     assert res.json().get('id') == 20
     # 断言 name
     assert res.json().get('name') == '碧螺春 12克*3袋'
     # 断言 price
     assert res.json().get('price') == '0.01'
예제 #13
0
 def test_theme_api(self):
     """专题栏"""
     # 请求返回数据
     res = ApiFactory.get_home_api().theme_api()
     # 打印请求地址  打印请求参数 打印请求响应数据
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     # 断言状态码
     assert res.status_code == 200
     # 断言id
     assert '"id":1' in res.text and '"id":2' in res.text and '"id":3' in res.text
     # 断言关键字段
     assert False not in [
         i in res.text
         for i in ["name", "description", "topic_img", "head_img"]
     ]
예제 #14
0
 def test_address(self, address_code, address_name, address_mobile):
     """
     地址
     :param address_code: 状态码
     :param address_name: 姓名
     :param address_mobile: 手机号
     :return:
     """
     # 请求
     res = ApiFactory.user_api().user_address()
     # 断言-状态码
     auto(self, res.status_code, address_code)
     # 断言-姓名
     auto(self, res.json().get("name"), address_name)
     # 断言-手机号
     auto(self, res.json().get("mobile"), address_mobile)
예제 #15
0
파일: testOrder.py 프로젝트: byf1/MiniPro
 def test_query_order(self):
     """查询订单"""
     # 订单id
     order_id = 119
     # 响应对象
     res = ApiFactory.get_order_api().query_order_api(order_id)
     # 打印请求地址,请求参数,请求响应数据
     logging.info(f"请求地址:{res.url}")
     logging.info(f"请求地址:{res.json()}")
     # 断言 状态码
     utils.common_assert_code(res)
     # 断言订单id
     assert res.json().get("id") == 119
     # 断言地址 用户名 手机号
     assert res.json().get("snap_address").get("name") == "大王"
     assert res.json().get("snap_address").get("mobile") == "13788888888"
예제 #16
0
    def test_query_order(self):
        """查询订单"""
        # 订单id
        order_id = 115
        # 响应对象
        res = ApiFactory.get_order_api().query_order_api(order_id)

        # 断言 状态码
        untils.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") == "13888888888"
예제 #17
0
    def test_classify_product_api(self):
        """分类下的商品"""
        # 请求返回数据
        res = ApiFactory.get_product_api().classify_product_api()
        # 打印请求地址,请求参数,请求响应数据
        logging.info(f"请求地址:{res.url}")
        logging.info(f"请求地址:{res.json()}")
        # 断言状态码
        utils.common_assert_code(res)

        # 断言关键字段name,description,topic_img,head_img
        assert False not in [
            i in res.text for i in
            ['name', 'id', 'price', 'stock', 'main_img_url', 'img_id']
        ]
        # 断言长度大于0
        assert len(res.json()) > 0
예제 #18
0
 def test_create_order(self):
     """创建订单"""
     # 购买商品id 、数量
     product_id = 15
     count = 2
     # 响应对象
     res = ApiFactory.get_order_api().create_order_api(product_id, count)
     # 打印 请求参数、请求地址、请求响应数据
     logging.info('请求地址:{}'.format(res.url))
     logging.info('请求响应:{}'.format(res.json()))
     # 断言响应状态码
     utils.common_assert(res)
     # 断言 order_no和order_id 存在
     assert len(res.json().get('order_no')) > 0 and len(
         res.json().get('order_id')) > 0
     # 断言订单状态
     assert res.json().get('pass') is True
예제 #19
0
    def test_order_list(self):
        """订单列表"""

        # 响应对象
        res = ApiFactory.get_order_api().order_list_api()
        # 断言 状态码
        untils.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"]
        ]
예제 #20
0
파일: testUserApi.py 프로젝트: yxkcc/mini3
 def test_address_api(self):
     res = ApiFactory.get_user_api().address_api()
     # 打印请求地址,打印请求参数 打印响应数据
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     # 断言响应状态码
     utils.common_assert_code(res, 200)
     # 大于0
     assert len(res.json()) > 0
     # 包含关键字
     # assert res.json().get('name') == '肖肖' and res.json().get('city') == '上海市' \
     #        and res.json().get('country') == '浦东区' \
     #        and res.json().get('mobile') == '13862812345'
     # 断言信息
     assert False not in [
         i in res.text for i in ['肖肖', '13862812345', '浦东区', '上海市']
     ]
예제 #21
0
파일: testOrder.py 프로젝트: byf1/MiniPro
 def test_order_list(self):
     """订单列表"""
     # 响应对象
     res = ApiFactory.get_order_api().order_list_api()
     # 打印请求地址,请求参数,请求响应数据
     logging.info(f"请求地址:{res.url}")
     logging.info(f"请求地址:{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"]
     ]
예제 #22
0
 def test_order_list_api(self):
     """订单列表"""
     res = ApiFactory.get_order_api().order_list_api()
     # 打印请求地址,打印请求参数 打印响应数据
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     # 断言状态码
     utils.common_assert_code(res, 200)
     # 断言订单数量大于0
     assert len(res.json().get('data')) > 0
     # 断言包含关键字段
     assert False not in [
         i in res.text
         for i in ['id', 'order_no', 'create_time', 'total_price']
     ]
     # 断言current_page的值
     assert res.json().get('current_page') == 1
예제 #23
0
    def test_product_classify_api(self):
        """商品分类"""
        # 请求响应对象
        res = ApiFactory.get_product_api().product_classify_api()
        # 打印请求地址,请求参数,请求响应数据
        logging.info(f"请求地址:{res.url}")
        logging.info(f"请求地址:{res.json()}")
        # 断言状态码
        utils.common_assert_code(res)

        # 断言关键字段name,description,topic_img,head_img
        assert False not in [
            i in res.text
            for i in ['name', 'id', 'topic_img_id', 'description']
        ]
        # 断言长度大于0
        assert len(res.json()) > 0
예제 #24
0
    def test_theme_api(self):
        """专题栏"""
        # 请求返回数据
        res = ApiFactory.get_home_api().theme_api()
        # 打印请求地址,请求参数,请求响应数据
        logging.info(f"请求地址:{res.url}")
        logging.info(f"请求地址:{res.json()}")

        # 断言状态码
        utils.common_assert_code(res)
        # 断言3个id
        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']
        ]
예제 #25
0
 def test_user_address(self):
     """用户地址信息"""
     # 获取返回数据
     res = ApiFactory.get_user_api().get_address_api()
     # 打印 请求参数、请求地址、请求响应数据
     logging.info('请求地址:{}'.format(res.url))
     logging.info('请求响应:{}'.format(res.json()))
     # 断言响应状态码
     utils.common_assert(res)
     # 断言 name
     assert res.json().get('name') == '小乔'
     # 断言 mobile
     assert res.json().get('mobile') == '13588888888'
     # 断言 地址信息
     assert False not in [
         i in res.text for i in ['上海市', '浦东新区', '航头镇航都路18号']
     ]
예제 #26
0
 def test_theme_api(self):
     """专题栏"""
     # 请求返回对象
     res = ApiFactory.get_home_api().theme_api()
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     # 断言状态码
     assert res.status_code == 200
     # 断言 - 三个id=1 2 3
     assert False not in [
         i in res.text for i in ['id":1', 'id":2', 'id":3']
     ]
     # 断言关键字段 name description topic_img head_img
     assert False not in [
         i in res.text
         for i in ["name", "description", "topic_img", "head_img"]
     ]
예제 #27
0
    def test_1token(self, token_code, token_length):
        """
        获取token
        :param token_code: 状态码
        :param token_length: token长度
        :return:
        """

        # 请求
        res = ApiFactory.user_api().create_token()
        # 断言 -状态码
        auto(self, res.status_code, token_code)
        # 断言 -token不为空
        auto(self, len(res.json()), token_length, "more")
        # 存储token到app.header
        app.header["token"] = res.json().get("token")
        print("app:{}".format(app.header))
예제 #28
0
파일: testHomeApi.py 프로젝트: yxkcc/mini3
 def test_theme_api(self):
     """专题栏"""
     res = ApiFactory.get_home_api().theme_api()
     # 打印请求地址,打印请求参数 打印响应数据
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     # 断言状态码
     utils.common_assert_code(res, 200)
     # 断言 三个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
     # ls = ['name', 'description', 'topic_img', 'head_img']
     # for i in ls:
     #     assert i in res.text
     assert False not in [
         i in res.text
         for i in ['name', 'description', 'topic_img', 'head_img']
     ]
예제 #29
0
파일: testOrder.py 프로젝트: lhq516/lhq1
    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"]
        ]
예제 #30
0
파일: testOrder.py 프로젝트: lhq516/lhq1
    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") == "13914151111"