Exemple #1
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
Exemple #2
0
 def test_banner_api(self):
     res = ApiFactory.get_home_api().banner_api()
     logging.info('请求地址:{}'.format(res.url))
     logging.info('响应数据:{}'.format(res.json()))
     # 断言响应状态码
     utils.comman_assert_method(res)
     # 断言id和name
     assert res.json().get("id") == 1 and res.json().get("name") == "首页置顶"
     # 断言items长度大于0
     assert len(res.json().get("items")) > 0
Exemple #3
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"]]
Exemple #4
0
    def test_recent_product_api(self):
        res = ApiFactory.get_home_api().recent_product_api()
        logging.info('请求地址:{}'.format(res.url))
        logging.info('响应数据:{}'.format(res.json()))

        # 断言响应状态码
        utils.comman_assert_method(res)

        # 断言关键字是否存在
        assert 'id' in res.text and 'name' in res.text and 'price' in res.text
Exemple #5
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
Exemple #6
0
 def test_recent_api(self):
     """最近新品"""
     res = ApiFactory.get_home_api().recent_api()
     # 打印请求地址 打印请求参数 打印请求响应数据
     logging.info("请求地址:{}".format(res.url))
     logging.info("响应数据:{}".format(res.json()))
     # 断言 -状态码
     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
Exemple #7
0
 def test_recent_product_api(self):
     """最近新品"""
     # 请求返回对象
     res = ApiFactory.get_home_api().product_recent_api()
     # 打印 请求地址,响应数据
     logging.info('请求地址:{}'.format(res.url))
     logging.info('响应数据:{}'.format(res.json()))
     # 断言状态码
     utils.common_assert_code(res)
     # 断言新品数量大于0
     assert len(res.json()) > 0
     # 断言关键字段 id, name, price
     assert False not in [i in res.text for i in ['id', 'name', 'price']]
Exemple #8
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)
     # 断言id 和 name
     assert res.json().get("id") == 1 and res.json().get("name") == "首页置顶"
     # 断言items列表长度大于0
     assert len(res.json().get("items")) > 0
Exemple #9
0
    def test_banner_api(self):
        """轮播图"""
        # 请求返回对象
        res = ApiFactory.get_home_api().banner_api()
        # 打印 请求地址,响应数据
        logging.info('请求地址:{}'.format(res.url))
        logging.info('响应数据:{}'.format(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
Exemple #10
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
     assert 'id":1' in res.text and 'id":2' in res.text and 'id":3' in res.text
     # 断言关键字段 description, topic_img, head_img
     assert False not in [
         i in res.text for i in ['description', 'topic_img', 'head_img']
     ]
Exemple #11
0
    def test_theme_api(self):
        res = ApiFactory.get_home_api().theme_api()
        logging.info('请求地址:{}'.format(res.url))
        logging.info('响应数据:{}'.format(res.json()))
        # 断言响应状态码
        utils.comman_assert_method(res)

        # 断言关键字段是否存在
        assert False not in [
            i in res.text for i in ['"id":1', '"id":2', '"id":3']
        ]
        # 断言关键字段是否存在
        assert False not in [
            i in res.text for i in ['name', 'topic_img', 'head_img']
        ]