def test_mis_login(self, account, password):
     # 获取登录响应对象
     r = self.mis.api_mis_login(account, password)
     print("后台管理系统登录成功后,请求headers:{}".format(api.headers))
     # 提取token值
     Tool.common_token(r)
     Tool.common_assert(r)
 def test01_mp_login(self, mobile, code):
     # 调用登录接口
     r = self.mp.api_mp_login(mobile, code)
     # 打印输出接口
     print("登录接口为:", json.dumps(r.json(), indent=2))
     # 提取token
     Tool.common_token(r)
     # 断言
     Tool.common_assert(r)
 def test_mp_article(self):
     # 1.调用发布文章接口
     r = self.mp.api_mp_article(title=api.title,
                                content=api.content,
                                channel_id=api.channel_id)
     # 2.提取文章id
     api.article_id = r.json().get("data").get("id")
     print("发布文章成功后的id:{}".format(api.article_id))
     # 3.断言
     Tool.common_assert(r)
예제 #4
0
 def test02_mis_search(self):
     # 1. 调用查询文章接口
     r = self.mis.api_mis_search()
     try:
         # 2. 断言
         Tool.common_assert(r, status_code=200)  # 注意:状态码为200并且为int型
     except Exception as e:
         # 1. 日志
         log.error(e)
         # 2. 抛异常
         raise
예제 #5
0
 def test03_mis_audit(self):
     # 1. 调用审核文章接口
     r = self.mis.api_mis_audit()
     try:
         # 2. 断言
         Tool.common_assert(r)
     except Exception as e:
         # 1. 日志
         log.error(e)
         # 2. 抛异常
         raise
예제 #6
0
 def test02_app_article(self):
     # 1. 调用查询接口
     r = self.app.api_app_article()
     try:
         # 2. 断言
         Tool.common_assert(r, status_code=200)
     except Exception as e:
         # 1. 日志
         log.error(e)
         # 2. 抛异常
         raise
예제 #7
0
 def test02_mis_search(self):
     # 1. 调用查询文章接口
     r = self.mis.api_mis_search()
     print("查询文章成功后:", r.json())
     try:
         # 2. 断言
         Tool.common_assert(r, status_code=200)
     except Exception as e:
         # 日志
         log.error(e)
         # 抛异常
         raise
예제 #8
0
 def test01_app_login(self, mobile, code):
     # 1. 调用登录接口
     r = self.app.api_app_login(mobile, code)
     # 2. 提取token
     Tool.common_token(r)
     try:
         # 3. 断言
         Tool.common_assert(r)
     except Exception as e:
         # 1. 日志
         log.error(e)
         # 2. 抛异常
         raise
예제 #9
0
 def test01_mis_login(self, account, password):
     # 1. 调用登录接口
     r = self.mis.api_mis_login(account, password)
     # 2. 提取token
     Tool.common_token(r)
     print("后台管理系统登录后,请求headers为:", api.headers)
     try:
         # 3. 断言
         Tool.common_assert(r)
     except Exception as e:
         # 1. 日志
         log.error(e)
         # 2. 抛异常
         raise
예제 #10
0
 def test01_mp_login(self, mobile, code):
     # 调用登录接口
     r = self.mp.api_mp_login(mobile, code)
     # 打印输出结果
     print("登录的结果为: ", r.json())
     try:
         # 提取token
         Tool.common_token(r)
         # 断言
         Tool.common_assert(r)
     except Exception as e:
         # 日志
         log.error(e)
         # 抛异常
         raise
예제 #11
0
 def test02_mp_article(self,
                       title=api.title,
                       content=api.content,
                       channel_id=api.channel_id):
     # 1. 调用发布文章接口
     r = self.mp.api_mp_article(title, content, channel_id)
     # 2. 提取id
     api.article_id = r.json().get("data").get("id")
     print("发布文章成功后的id值为:", api.article_id)
     try:
         # 3. 断言
         Tool.common_assert(r)
     except Exception as e:
         # 1. 日志
         log.error(e)
         # 2. 抛异常
         raise
예제 #12
0
class TestApp:
    # 初始化
    def setup_class(self):
        # 获取ApiApp对象
        self.app = ApiApp()
        # 获取Tool对象
        self.tool = Tool()

    # 登录测试方法
    @pytest.mark.parametrize("mobile,code", read_yaml("app_login.yaml"))
    def test01_app_login(self, mobile, code):
        # 调用登录业务方法
        response = self.app.api_app_login(mobile, code)
        print("App登录后的数据为:", response.json())
        # 断言
        self.tool.assert_code_message(response)
        # 提取token
        self.tool.get_token(response)
        print("App登录后提取的token信息:", api.headers)

    # 查询文章测试方法
    def test02_search_article(self):
        # 调用查询业务方法
        response = self.app.api_search_article()
        print("App搜文章的值为:", response.json())
        # 断言
        self.tool.assert_code_message(response, code=200)
예제 #13
0
class TestMis:
    # 初始化
    def setup_class(self):
        # 后去ApiMis对象
        self.mis = ApiMis()
        # 获取Tool对象
        self.tool = Tool()

    # 登录
    @pytest.mark.parametrize("account,password", read_yaml("mis_login.yaml"))
    def test01_mis_login(self, account, password):
        # 调用登录业务方法
        response = self.mis.api_mis_login(account, password)
        print("后台登录数据:", response.json())
        # 断言
        self.tool.assert_code_message(response)
        # 提取 token
        self.tool.get_token(response)
        print("提取的token值为:", api.headers)
        print("--" * 50)

    # 查询
    def test02_mis_search(self):
        # 调用查询业务方法
        response = self.mis.api_search_article()
        print("--" * 50)
        print("查询结果为:", response.json())
        # 断言
        self.tool.assert_code_message(response, code=200)

    # 审核
    def test03_mis_audit(self):
        # 调用审核业务方法
        response = self.mis.api_audit()
        print("--" * 50)
        print("审核结果为:", response.json())
        # 断言
        self.tool.assert_code_message(response)
 def test_mis_audit(self):
     # 获取审核文章接口响应对象
     r = self.mis.api_mis_audit()
     Tool.common_assert(r)
 def test_mis_search(self):
     # 获取文章查询接口响应对象
     r = self.mis.api_mis_search()
     Tool.common_assert(r, status_code=200)
예제 #16
0
 def setup_class(self):
     # 获取ApiApp对象
     self.app = ApiApp()
     # 获取Tool对象
     self.tool = Tool()
예제 #17
0
 def setup_class(self):
     # 后去ApiMis对象
     self.mis = ApiMis()
     # 获取Tool对象
     self.tool = Tool()
 def test_app_login(self, mobile, code):
     # 调用APP登录接口响应对象
     r = self.app.api_app_login(mobile, code)
     # 断言
     Tool.common_token(r)
     Tool.common_assert(r)
 def test_app_channel_article(self):
     # 调用APP查看频道文章接口响应对象
     r = self.app.api_app_channel_article()
     # 断言
     Tool.common_assert(r, status_code=200)