Ejemplo n.º 1
0
    def test_user_login(self, index, casesname, module, id):
        body = handle_datas.handleDatas(
            globals()['sheet_id']).get_request_parameter(index)
        headers = handle_datas.handleDatas(
            globals()['sheet_id']).get_request_headers(index, body)
        path = TestUserLogin.datas.get_request_url(index)
        url = readConfig.ReadConfig.get_http('baseurl') + path
        except_data = TestUserLogin.datas.get_expect_data(index)

        try:
            if TestUserLogin.datas.get_request_method(index) == 'post':
                response = requests.post(url,
                                         json=body,
                                         headers=headers,
                                         verify=False)
            else:
                response = requests.get(url, params=body, headers=headers)

            handle_datas.handleDatas(
                globals()['sheet_id']).get_data_from_response(
                    index, response.json())  # 保存需要保存的数据
            handleResult.out_print(url, headers, body, response)

        except Exception as e:
            print("报错了", e)

        handleResult.result_assert(response.text, response.status_code,
                                   except_data)  # 断言,判断接口状态和预期结果
Ejemplo n.º 2
0
    def test_homepage(self, index, casesname, module, id):
        body = handle_datas.handleDatas(
            globals()['sheet_id']).get_request_parameter(index)
        headers = handle_datas.handleDatas(
            globals()['sheet_id']).get_request_headers(index, body)
        path = TestHomePage.datas.get_request_url(index)
        url = readConfig.ReadConfig.get_http('baseurl') + path
        except_data = TestHomePage.datas.get_expect_data(index)

        try:
            if TestHomePage.datas.get_request_method(index) == 'post':
                response = requests.post(url,
                                         json=body,
                                         headers=headers,
                                         verify=False)

            else:
                response = requests.get(url, params=body, headers=headers)
            handle_datas.handleDatas(
                globals()['sheet_id']).get_data_from_response(
                    index, response.json())  # 保存需要保存的数据
            handleResult.out_print(url, headers, body, response)

        except Exception as e:
            print("报错了", e)