expect = "" # 预期结果 # --------------------分界线,下边的不要修改----------------------------------------- # method,pub_data和url为必传字段 request_tool.request(method=method, url=uri, pub_data=pub_data, files=files, status_code=status_code, expect=expect, feature=feature, story=story, title=title, headers=headers) data = excel_tool.get_test_case("e:\\工作簿1.xlsx") @pytest.mark.parametrize("account_name,amount,expect_", data[1], ids=data[0]) def test_charge(pub_data, account_name, amount, expect_): pub_data["account_name"] = account_name pub_data["amount"] = amount method = "POST" #请求方法,全部大写 feature = "账户模块" # allure报告中一级分类 story = '充值' # allure报告中二级分类 title = None # allure报告中用例名字 uri = "/acc/recharge" # 接口地址 # headers={"token":"${token}"} # post请求json数据,注意数据格式为字典或者为json串 为空写None json_data = ''' {
# method,pub_data和url为必传字段 r = request_tool.request(method=method, url=uri, pub_data=pub_data, params=params, status_code=status_code, expect=expect, feature=feature, story=story, title=title, headers=headers) with open(file_name, "wb") as f: f.write(r.content) data = excel_tool.get_test_case("e:\\test.xls") @pytest.mark.parametrize("account_name,amount,expect_", data[1], ids=data[0]) def test_recharge(pub_data, account_name, amount, expect_): pub_data["account_name"] = account_name pub_data["amount"] = amount method = "POST" #请求方法,全部大写 feature = "账户模块" # allure报告中一级分类 story = '充值' # allure报告中二级分类 title = None uri = "/acc/recharge" # 接口地址 headers = {"token": "${token}"} status_code = 200 # 响应状态码 expect = expect_ # 预期结果 json_data = '''{
story = '盘点库存' # allure报告中二级分类 title = "盘点库存" # allure报告中用例名字 uri = "/product/uploaProdRepertory" # 接口地址 # post请求json数据,注意数据格式为字典或者为json串 为空写None files = {"file":open(file_name,'rb')} headers = {"token": "${token}"} status_code = 200 # 响应状态码 expect = "2000" # 预期结果 # --------------------分界线,下边的不要修改----------------------------------------- # method,pub_data和url为必传字段 request_tool.request(method=method,url=uri,pub_data=pub_data,files=files,status_code=status_code,expect=expect,feature=feature,story=story,title=title,headers=headers) import pytest from tools.data import excel_tool data = excel_tool.get_test_case("d:\\充值接口测试数据.xlsx") @pytest.mark.parametrize("account_name,amount,expect_",data[1],ids=data[0]) def test_charge(pub_data,account_name,amount,expect_): pub_data["account_name"] = account_name pub_data["amount"] = amount method = "POST" #请求方法,全部大写 feature = "用户模块" # allure报告中一级分类 story = '充值' # allure报告中二级分类 title = None # allure报告中用例名字 uri = "/acc/recharge" # 接口地址 # post请求json数据,注意数据格式为字典或者为json串 为空写None print(expect_) json_data = ''' { "accountName": "${account_name}",
# method,pub_data和url为必传字段 r = request_tool.request(method=method, url=uri, pub_data=pub_data, params=params, status_code=status_code, expect=expect, feature=feature, story=story, title=title, headers=headers) with open(file_name, "wb") as f: f.write(r.content) data = excel_tool.get_test_case("E:\\充值接口测试数据.xls") @pytest.mark.parametrize("account_name,money,expect", data[1], ids=data[0]) def test_recharge(pub_data, account_name, money, expect): pub_data["account_name"] = account_name pub_data["money"] = money method = "POST" #请求方法,全部大写 feature = "用户模块" # allure报告中一级分类 story = '用户充值' # allure报告中二级分类 uri = "/acc/recharge" # 接口地址 headers = {} status_code = 200 # 响应状态码 expect = "" # 预期结果 json_data = '''{ "accountName": "${account_name}",
story = '盘点库存' # allure报告中二级分类 title = "盘点库存" # allure报告中用例名字 uri = "/product/uploaProdRepertory" # 接口地址 # post请求json数据,注意数据格式为字典或者为json串 为空写None files = {"file":open(file_name,'rb')} headers={"token":"${token}"} status_code = 200 # 响应状态码 expect = "" # 预期结果 # --------------------分界线,下边的不要修改----------------------------------------- # method,pub_data和url为必传字段 request_tool.request(method=method,url=uri,pub_data=pub_data,files=files,status_code=status_code,expect=expect,feature=feature,story=story,title=title,headers=headers) data = excel_tool.get_test_case("E:\\充值接口测试.xls") @pytest.mark.parametrize("accountname,changeMoney,expect",data[1],ids=data[0]) def test_post_json(pub_data,accountname,changeMoney,expect): pub_data["accountname"] = accountname pub_data["changeMoney"] = changeMoney method = "POST" #请求方法,全部大写 feature = "用户模块" # allure报告中一级分类 story = '充值' # allure报告中二级分类 title = "全字段正常流_1" # allure报告中用例名字 uri = "/acc/recharge" # 接口地址 # post请求json数据,注意数据格式为字典或者为json串 为空写None json_data = ''' { "accountName": "${accountname}", "changeMoney": "${changeMoney}" }
expect = "2000" # 预期结果 # --------------------分界线,下边的不要修改----------------------------------------- # method,pub_data和url为必传字段 request_tool.request(method=method, url=uri, pub_data=pub_data, files=files, status_code=status_code, expect=expect, feature=feature, story=story, title=title, headers=headers) data = excel_tool.get_test_case("d:\\充值测试.xlsx") @pytest.mark.parametrize("account_name,changeMoney,expect_", data[1], ids=data[0]) def test_post_chonbgzhi(pub_data, account_name, changeMoney, expect_): pub_data["account_name"] = account_name pub_data["changeMoney"] = changeMoney method = "POST" #请求方法,全部大写 feature = "账户模块" # allure报告中一级分类 story = '账户充值' # allure报告中二级分类 title = None # allure报告中用例名字 uri = "/acc/recharge" # 接口地址 headers = {"token": "${token}"} # post请求json数据,注意数据格式为字典或者为json串 为空写None
expect = "2000" # 预期结果 # --------------------分界线,下边的不要修改----------------------------------------- # method,pub_data和url为必传字段 request_tool.request(method=method, url=uri, pub_data=pub_data, files=files, status_code=status_code, expect=expect, feature=feature, story=story, title=title, headers=headers) data = excel_tool.get_test_case("e:\\充值接口.xls") @pytest.mark.parametrize("account_name,amount,expect", data[1], ids=data[0]) def test_recharge(pub_data, account_name, amount, expect): pub_data["account_name"] = account_name pub_data["amount"] = amount method = "POST" #请求方法,全部大写 feature = "用户模块" # allure报告中一级分类 story = '用户充值' # allure报告中二级分类 uri = "/acc/recharge" # 接口地址 headers = {"token": "${token}"} status_code = 200 # 响应状态码 expect = expect # 预期结果 json_data = '''{ "accountName": "${account_name}",
expect = "" # 预期结果 # --------------------分界线,下边的不要修改----------------------------------------- # method,pub_data和url为必传字段 request_tool.request(method=method, url=uri, pub_data=pub_data, files=files, status_code=status_code, expect=expect, feature=feature, story=story, title=title, headers=headers) data = excel_tool.get_test_case("D:\\充值接口测试.xls") @pytest.mark.parametrize("account_name,money,expect", data[1], ids=data[0]) def test_post_json(pub_data, account_name, money, expect): pub_data["account_name"] = account_name pub_data["money"] = money method = "POST" #请求方法,全部大写 feature = "用户模块" # allure报告中一级分类 story = '充值' # allure报告中二级分类 title = "全字段正常流_1" # allure报告中用例名字 uri = "/acc/recharge" # 接口地址 # post请求json数据,注意数据格式为字典或者为json串 为空写None json_data = ''' { "accountName": "${account_name}",
method = "POST" #请求方法,全部大写 feature = "库存模块" # allure报告中一级分类 story = '盘点库存' # allure报告中二级分类 title = "盘点库存" # allure报告中用例名字 uri = "/product/uploaProdRepertory" # 接口地址 # post请求json数据,注意数据格式为字典或者为json串 为空写None files = {"file":open(file_name,'rb')} headers={"token":"${token}"} status_code = 200 # 响应状态码 expect = "" # 预期结果 # --------------------分界线,下边的不要修改----------------------------------------- # method,pub_data和url为必传字段 request_tool.request(method=method,url=uri,pub_data=pub_data,files=files,status_code=status_code,expect=expect,feature=feature,story=story,title=title,headers=headers) data = excel_tool.get_test_case("d:\\charge_api.xlsx") @pytest.mark.parametrize("account_name,charge,expect_status",data[1],ids=data[0]) def test_post_json(pub_data,account_name,charge,expect_status): pub_data["account_name"] = account_name pub_data["charge"] = charge method = "POST" #请求方法,全部大写 feature = "账户模块" # allure报告中一级分类 story = '充值' # allure报告中二级分类 title = "" # allure报告中用例名字 uri = "/acc/recharge" # 接口地址 # post请求json数据,注意数据格式为字典或者为json串 为空写None json_data = ''' { "accountName": "${account_name}", "changeMoney": "${charge}" }