コード例 #1
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)
コード例 #2
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)