Merge branch 'dev'
This commit is contained in:
commit
cb572da6c8
|
@ -0,0 +1,3 @@
|
|||
|
||||
*.xml
|
||||
*.pyc
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
[{"status":"COMPLETE","method":"POST","protocolVersion":"HTTP/1.1","scheme":"http","host":"10.88.88.141","port":20037,"actualPort":20037,"path":"/api/register/addOrUpCurBact","query":null,"tunnel":false,"keptAlive":true,"webSocket":false,"remoteAddress":"10.88.88.141/10.88.88.141","clientAddress":"/127.0.0.1","clientPort":59267,"times":{"start":"2021-02-04T08:35:57.615+08:00","requestBegin":"2021-02-04T08:35:57.616+08:00","requestComplete":"2021-02-04T08:35:57.617+08:00","responseBegin":"2021-02-04T08:35:57.636+08:00","end":"2021-02-04T08:35:57.637+08:00"},"durations":{"total":21,"dns":null,"connect":null,"ssl":null,"request":1,"response":1,"latency":19},"speeds":{"overall":"72809","request":"1058000","response":"471000"},"totalSize":"1529","request":{"sizes":{"headers":485,"body":573},"mimeType":"application/x-www-form-urlencoded","charset":"UTF-8","contentEncoding":null,"header":{"firstLine":"POST /api/register/addOrUpCurBact HTTP/1.1","headers":[{"name":"Host","value":"10.88.88.141:20037"},{"name":"Content-Length","value":"573"},{"name":"Accept","value":"application/json, text/plain, */*"},{"name":"User-Agent","value":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"},{"name":"Content-Type","value":"application/x-www-form-urlencoded;charset=UTF-8"},{"name":"Origin","value":"http://10.88.88.141:6006"},{"name":"Referer","value":"http://10.88.88.141:6006/"},{"name":"Accept-Encoding","value":"gzip, deflate"},{"name":"Accept-Language","value":"zh-CN,zh;q=0.9"},{"name":"Connection","value":"keep-alive"}]},"body":{"text":"{\"params\":{\"pageType\":\"0\",\"unitCode\":\"3202112002\",\"bactCode\":\"280101\",\"materType\":\"86901119000052\",\"coreName\":\"大连雅立峰\",\"corpSimpName\":\"大连雅立峰\",\"materName\":\"狂犬病疫苗(vero细胞)\",\"inocCorpCode\":\"50\",\"speCodeName\":\"1.0ml\",\"vaccSpeCode\":\"1002\",\"pym\":\"kqbymveroxb\",\"price\":\"0\",\"batnmb\":\"20110101\",\"qty\":\"100\",\"ifUse\":1,\"dataType\":2,\"createDate\":\"\",\"createManCode\":\"3202112002008\",\"modifyDate\":\"\",\"modifyManCode\":\"3202112002008\",\"bactValidate\":\"2022-02-02\",\"bizType\":1,\"materTypeCode\":\"1\"},\"headtoken\":\"/8QPAj9LlNJ1MaPd9ykD9cHql4tf3Xw/fu+VnRGKtCw=\"}","charset":"UTF-8"}},"response":{"status":200,"sizes":{"headers":394,"body":77},"mimeType":"application/json","charset":"UTF-8","contentEncoding":null,"header":{"firstLine":"HTTP/1.1 200 ","headers":[{"name":"Server","value":"nginx/1.14.2"},{"name":"Date","value":"Thu, 04 Feb 2021 00:30:02 GMT"},{"name":"Content-Type","value":"application/json;charset=UTF-8"},{"name":"Content-Length","value":"77"},{"name":"Access-Control-Allow-Headers","value":"Content-Type,x-requested-with,Authorization,Access-Control-Allow-Origin"},{"name":"Access-Control-Allow-Methods","value":"POST, GET, OPTIONS"},{"name":"Access-Control-Allow-Origin","value":"*"},{"name":"Access-Control-Max-Age","value":"360"},{"name":"Proxy-Connection","value":"keep-alive"}]},"body":{"text":"{\"success\":true,\"code\":null,\"msg\":\"返回成功\",\"data\":null,\"callTime\":null}","charset":"UTF-8"}}}]
|
||||
[{"status":"COMPLETE","method":"POST","protocolVersion":"HTTP/1.1","scheme":"http","host":"127.0.0.1","port":20037,"actualPort":20037,"path":"/api/register/addOrUpCurBact","query":null,"tunnel":false,"keptAlive":true,"webSocket":false,"remoteAddress":"127.0.0.1/127.0.0.1","clientAddress":"/127.0.0.1","clientPort":59267,"times":{"start":"2021-02-04T08:35:57.615+08:00","requestBegin":"2021-02-04T08:35:57.616+08:00","requestComplete":"2021-02-04T08:35:57.617+08:00","responseBegin":"2021-02-04T08:35:57.636+08:00","end":"2021-02-04T08:35:57.637+08:00"},"durations":{"total":21,"dns":null,"connect":null,"ssl":null,"request":1,"response":1,"latency":19},"speeds":{"overall":"72809","request":"1058000","response":"471000"},"totalSize":"1529","request":{"sizes":{"headers":485,"body":573},"mimeType":"application/x-www-form-urlencoded","charset":"UTF-8","contentEncoding":null,"header":{"firstLine":"POST /api/register/addOrUpCurBact HTTP/1.1","headers":[{"name":"Host","value":"127.0.0.1:20037"},{"name":"Content-Length","value":"573"},{"name":"Accept","value":"application/json, text/plain, */*"},{"name":"User-Agent","value":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"},{"name":"Content-Type","value":"application/x-www-form-urlencoded;charset=UTF-8"},{"name":"Origin","value":"http://127.0.0.1:6006"},{"name":"Referer","value":"http://127.0.0.1:6006/"},{"name":"Accept-Encoding","value":"gzip, deflate"},{"name":"Accept-Language","value":"zh-CN,zh;q=0.9"},{"name":"Connection","value":"keep-alive"}]},"body":{"text":"{\"params\":{\"pageType\":\"0\",\"unitCode\":\"3202112002\",\"bactCode\":\"280101\",\"materType\":\"86901119000052\",\"coreName\":\"大连雅立峰\",\"corpSimpName\":\"大连雅立峰\",\"materName\":\"狂犬病疫苗(vero细胞)\",\"inocCorpCode\":\"50\",\"speCodeName\":\"1.0ml\",\"vaccSpeCode\":\"1002\",\"pym\":\"kqbymveroxb\",\"price\":\"0\",\"batnmb\":\"20110101\",\"qty\":\"100\",\"ifUse\":1,\"dataType\":2,\"createDate\":\"\",\"createManCode\":\"3202112002008\",\"modifyDate\":\"\",\"modifyManCode\":\"3202112002008\",\"bactValidate\":\"2022-02-02\",\"bizType\":1,\"materTypeCode\":\"1\"},\"headtoken\":\"/8QPAj9LlNJ1MaPd9ykD9cHql4tf3Xw/fu+VnRGKtCw=\"}","charset":"UTF-8"}},"response":{"status":200,"sizes":{"headers":394,"body":77},"mimeType":"application/json","charset":"UTF-8","contentEncoding":null,"header":{"firstLine":"HTTP/1.1 200 ","headers":[{"name":"Server","value":"nginx/1.14.2"},{"name":"Date","value":"Thu, 04 Feb 2021 00:30:02 GMT"},{"name":"Content-Type","value":"application/json;charset=UTF-8"},{"name":"Content-Length","value":"77"},{"name":"Access-Control-Allow-Headers","value":"Content-Type,x-requested-with,Authorization,Access-Control-Allow-Origin"},{"name":"Access-Control-Allow-Methods","value":"POST, GET, OPTIONS"},{"name":"Access-Control-Allow-Origin","value":"*"},{"name":"Access-Control-Max-Age","value":"360"},{"name":"Proxy-Connection","value":"keep-alive"}]},"body":{"text":"{\"success\":true,\"code\":null,\"msg\":\"返回成功\",\"data\":null,\"callTime\":null}","charset":"UTF-8"}}}]
|
|
@ -1 +1 @@
|
|||
[{"status":"COMPLETE","method":"POST","protocolVersion":"HTTP/1.1","scheme":"http","host":"10.88.88.141","port":20037,"actualPort":20037,"path":"/api/register/findParam","query":null,"tunnel":false,"keptAlive":false,"webSocket":false,"remoteAddress":"10.88.88.141/10.88.88.141","clientAddress":"/127.0.0.1","clientPort":59266,"times":{"start":"2021-02-04T08:35:25.301+08:00","requestBegin":"2021-02-04T08:35:25.303+08:00","requestComplete":"2021-02-04T08:35:25.303+08:00","responseBegin":"2021-02-04T08:35:25.318+08:00","end":"2021-02-04T08:35:25.319+08:00"},"durations":{"total":17,"dns":0,"connect":1,"ssl":null,"request":0,"response":1,"latency":15},"speeds":{"overall":"64294","request":"0","response":"476000"},"totalSize":"1093","request":{"sizes":{"headers":480,"body":137},"mimeType":"application/x-www-form-urlencoded","charset":"UTF-8","contentEncoding":null,"header":{"firstLine":"POST /api/register/findParam HTTP/1.1","headers":[{"name":"Host","value":"10.88.88.141:20037"},{"name":"Content-Length","value":"137"},{"name":"Accept","value":"application/json, text/plain, */*"},{"name":"User-Agent","value":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"},{"name":"Content-Type","value":"application/x-www-form-urlencoded;charset=UTF-8"},{"name":"Origin","value":"http://10.88.88.141:6006"},{"name":"Referer","value":"http://10.88.88.141:6006/"},{"name":"Accept-Encoding","value":"gzip, deflate"},{"name":"Accept-Language","value":"zh-CN,zh;q=0.9"},{"name":"Connection","value":"keep-alive"}]},"body":{"text":"{\"params\":{\"unitCode\":\"3202112002\",\"first\":0,\"pym\":\"\",\"pageSize\":10,\"page\":0},\"headtoken\":\"/8QPAj9LlNJ1MaPd9ykD9cHql4tf3Xw/fu+VnRGKtCw=\"}","charset":"UTF-8"}},"response":{"status":200,"sizes":{"headers":394,"body":82},"mimeType":"application/json","charset":"UTF-8","contentEncoding":null,"header":{"firstLine":"HTTP/1.1 200 ","headers":[{"name":"Server","value":"nginx/1.14.2"},{"name":"Date","value":"Thu, 04 Feb 2021 00:29:29 GMT"},{"name":"Content-Type","value":"application/json;charset=UTF-8"},{"name":"Content-Length","value":"82"},{"name":"Access-Control-Allow-Headers","value":"Content-Type,x-requested-with,Authorization,Access-Control-Allow-Origin"},{"name":"Access-Control-Allow-Methods","value":"POST, GET, OPTIONS"},{"name":"Access-Control-Allow-Origin","value":"*"},{"name":"Access-Control-Max-Age","value":"360"},{"name":"Proxy-Connection","value":"keep-alive"}]},"body":{"text":"{\"success\":true,\"code\":null,\"msg\":\"返回成功\",\"data\":[\"1\",\"1\"],\"callTime\":null}","charset":"UTF-8"}}}]
|
||||
[{"status":"COMPLETE","method":"POST","protocolVersion":"HTTP/1.1","scheme":"http","host":"127.0.0.1","port":20037,"actualPort":20037,"path":"/api/register/findParam","query":null,"tunnel":false,"keptAlive":false,"webSocket":false,"remoteAddress":"127.0.0.1/127.0.0.1","clientAddress":"/127.0.0.1","clientPort":59266,"times":{"start":"2021-02-04T08:35:25.301+08:00","requestBegin":"2021-02-04T08:35:25.303+08:00","requestComplete":"2021-02-04T08:35:25.303+08:00","responseBegin":"2021-02-04T08:35:25.318+08:00","end":"2021-02-04T08:35:25.319+08:00"},"durations":{"total":17,"dns":0,"connect":1,"ssl":null,"request":0,"response":1,"latency":15},"speeds":{"overall":"64294","request":"0","response":"476000"},"totalSize":"1093","request":{"sizes":{"headers":480,"body":137},"mimeType":"application/x-www-form-urlencoded","charset":"UTF-8","contentEncoding":null,"header":{"firstLine":"POST /api/register/findParam HTTP/1.1","headers":[{"name":"Host","value":"127.0.0.1:20037"},{"name":"Content-Length","value":"137"},{"name":"Accept","value":"application/json, text/plain, */*"},{"name":"User-Agent","value":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"},{"name":"Content-Type","value":"application/x-www-form-urlencoded;charset=UTF-8"},{"name":"Origin","value":"http://127.0.0.1:6006"},{"name":"Referer","value":"http://127.0.0.1:6006/"},{"name":"Accept-Encoding","value":"gzip, deflate"},{"name":"Accept-Language","value":"zh-CN,zh;q=0.9"},{"name":"Connection","value":"keep-alive"}]},"body":{"text":"{\"params\":{\"unitCode\":\"3202112002\",\"first\":0,\"pym\":\"\",\"pageSize\":10,\"page\":0},\"headtoken\":\"/8QPAj9LlNJ1MaPd9ykD9cHql4tf3Xw/fu+VnRGKtCw=\"}","charset":"UTF-8"}},"response":{"status":200,"sizes":{"headers":394,"body":82},"mimeType":"application/json","charset":"UTF-8","contentEncoding":null,"header":{"firstLine":"HTTP/1.1 200 ","headers":[{"name":"Server","value":"nginx/1.14.2"},{"name":"Date","value":"Thu, 04 Feb 2021 00:29:29 GMT"},{"name":"Content-Type","value":"application/json;charset=UTF-8"},{"name":"Content-Length","value":"82"},{"name":"Access-Control-Allow-Headers","value":"Content-Type,x-requested-with,Authorization,Access-Control-Allow-Origin"},{"name":"Access-Control-Allow-Methods","value":"POST, GET, OPTIONS"},{"name":"Access-Control-Allow-Origin","value":"*"},{"name":"Access-Control-Max-Age","value":"360"},{"name":"Proxy-Connection","value":"keep-alive"}]},"body":{"text":"{\"success\":true,\"code\":null,\"msg\":\"返回成功\",\"data\":[\"1\",\"1\"],\"callTime\":null}","charset":"UTF-8"}}}]
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,12 +1,12 @@
|
|||
test_info:
|
||||
title: perRelated
|
||||
host: ${host}
|
||||
scheme: http
|
||||
scheme: ${scheme}
|
||||
method: POST
|
||||
address: /api/perRelated/addAudltCard
|
||||
mime_type: application/x-www-form-urlencoded
|
||||
headers: ${headers}
|
||||
timeout: 10
|
||||
timeout: ${timeout}
|
||||
file: false
|
||||
cookies: false
|
||||
premise: false
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
test_info:
|
||||
title: register
|
||||
host: ${host}
|
||||
scheme: http
|
||||
scheme: ${scheme}
|
||||
method: POST
|
||||
address: /api/register/addOrUpCurBact
|
||||
mime_type: application/x-www-form-urlencoded
|
||||
headers: ${headers}
|
||||
timeout: 10
|
||||
timeout: ${timeout}
|
||||
file: false
|
||||
cookies: false
|
||||
premise: /register/test_getAdultCurbactList.yaml
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
test_info:
|
||||
title: register
|
||||
host: ${host}
|
||||
scheme: http
|
||||
scheme: ${scheme}
|
||||
method: POST
|
||||
address: /api/register/findParam
|
||||
mime_type: application/x-www-form-urlencoded
|
||||
headers: ${headers}
|
||||
timeout: 10
|
||||
timeout: ${timeout}
|
||||
file: false
|
||||
cookies: false
|
||||
premise: false
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
test_info:
|
||||
title: register
|
||||
host: ${host}
|
||||
scheme: http
|
||||
scheme: ${scheme}
|
||||
method: POST
|
||||
address: /api/register/getAdultCurbactList
|
||||
mime_type: application/x-www-form-urlencoded
|
||||
headers: ${headers}
|
||||
timeout: 10
|
||||
timeout: ${timeout}
|
||||
file: false
|
||||
cookies: false
|
||||
premise: false
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
test_info:
|
||||
title: register
|
||||
host: ${host}
|
||||
scheme: http
|
||||
scheme: ${scheme}
|
||||
method: POST
|
||||
address: /api/register/initCanSelInfo
|
||||
mime_type: application/x-www-form-urlencoded
|
||||
headers: ${headers}
|
||||
timeout: 10
|
||||
timeout: ${timeout}
|
||||
file: false
|
||||
cookies: false
|
||||
premise: false
|
||||
|
|
|
@ -10,20 +10,20 @@ from comm.utils.readYaml import read_yaml_data
|
|||
from comm.unit.initializePremise import init_premise
|
||||
from comm.unit.apiSend import send_request
|
||||
from comm.unit.checkResult import check_result
|
||||
case_yaml = os.path.realpath(__file__).replace('testcase', 'page').replace('.py', '.yaml')
|
||||
case_path = os.path.dirname(case_yaml)
|
||||
case_dict = read_yaml_data(case_yaml)
|
||||
file_path = os.path.realpath(__file__).replace('\\', '/')
|
||||
case_yaml = file_path.replace('/testcase/', '/page/').replace('.py', '.yaml')
|
||||
test_case = read_yaml_data(case_yaml)
|
||||
|
||||
|
||||
@allure.feature(case_dict["test_info"]["title"])
|
||||
@allure.feature(test_case["test_info"]["title"])
|
||||
class TestPerrelated:
|
||||
|
||||
@pytest.mark.parametrize("case_data", case_dict["test_case"])
|
||||
@pytest.mark.parametrize("test_case", test_case["test_case"])
|
||||
@allure.story("test_addAudltCard")
|
||||
def test_addAudltCard(self, case_data):
|
||||
def test_addAudltCard(self, test_case):
|
||||
# 初始化请求:执行前置接口+替换关联变量
|
||||
test_info, case_data = init_premise(case_dict["test_info"], case_data, case_path)
|
||||
test_info, test_case = init_premise(test_case["test_info"], test_case, case_yaml)
|
||||
# 发送当前接口
|
||||
code, data = send_request(test_info, case_data)
|
||||
code, data = send_request(test_info, test_case)
|
||||
# 校验接口返回
|
||||
check_result(case_data, code, data)
|
||||
check_result(test_case, code, data)
|
||||
|
|
|
@ -10,20 +10,20 @@ from comm.utils.readYaml import read_yaml_data
|
|||
from comm.unit.initializePremise import init_premise
|
||||
from comm.unit.apiSend import send_request
|
||||
from comm.unit.checkResult import check_result
|
||||
case_yaml = os.path.realpath(__file__).replace('testcase', 'page').replace('.py', '.yaml')
|
||||
case_path = os.path.dirname(case_yaml)
|
||||
case_dict = read_yaml_data(case_yaml)
|
||||
file_path = os.path.realpath(__file__).replace('\\', '/')
|
||||
case_yaml = file_path.replace('/testcase/', '/page/').replace('.py', '.yaml')
|
||||
case_data = read_yaml_data(case_yaml)
|
||||
|
||||
|
||||
@allure.feature(case_dict["test_info"]["title"])
|
||||
@allure.feature(case_data["test_info"]["title"])
|
||||
class TestRegister:
|
||||
|
||||
@pytest.mark.parametrize("case_data", case_dict["test_case"])
|
||||
@pytest.mark.parametrize("test_case", case_data["test_case"])
|
||||
@allure.story("test_addOrUpCurBact")
|
||||
def test_addOrUpCurBact(self, case_data):
|
||||
def test_addOrUpCurBact(self, test_case):
|
||||
# 初始化请求:执行前置接口+替换关联变量
|
||||
test_info, case_data = init_premise(case_dict["test_info"], case_data, case_path)
|
||||
test_info, test_case = init_premise(case_data["test_info"], test_case, case_yaml)
|
||||
# 发送当前接口
|
||||
code, data = send_request(test_info, case_data)
|
||||
code, data = send_request(test_info, test_case)
|
||||
# 校验接口返回
|
||||
check_result(case_data, code, data)
|
||||
check_result(test_case, code, data)
|
||||
|
|
|
@ -10,20 +10,20 @@ from comm.utils.readYaml import read_yaml_data
|
|||
from comm.unit.initializePremise import init_premise
|
||||
from comm.unit.apiSend import send_request
|
||||
from comm.unit.checkResult import check_result
|
||||
case_yaml = os.path.realpath(__file__).replace('testcase', 'page').replace('.py', '.yaml')
|
||||
case_path = os.path.dirname(case_yaml)
|
||||
case_dict = read_yaml_data(case_yaml)
|
||||
file_path = os.path.realpath(__file__).replace('\\', '/')
|
||||
case_yaml = file_path.replace('/testcase/', '/page/').replace('.py', '.yaml')
|
||||
test_case = read_yaml_data(case_yaml)
|
||||
|
||||
|
||||
@allure.feature(case_dict["test_info"]["title"])
|
||||
@allure.feature(test_case["test_info"]["title"])
|
||||
class TestRegister:
|
||||
|
||||
@pytest.mark.parametrize("case_data", case_dict["test_case"])
|
||||
@pytest.mark.parametrize("test_case", test_case["test_case"])
|
||||
@allure.story("test_findParam")
|
||||
def test_findParam(self, case_data):
|
||||
def test_findParam(self, test_case):
|
||||
# 初始化请求:执行前置接口+替换关联变量
|
||||
test_info, case_data = init_premise(case_dict["test_info"], case_data, case_path)
|
||||
test_info, test_case = init_premise(test_case["test_info"], test_case, case_yaml)
|
||||
# 发送当前接口
|
||||
code, data = send_request(test_info, case_data)
|
||||
code, data = send_request(test_info, test_case)
|
||||
# 校验接口返回
|
||||
check_result(case_data, code, data)
|
||||
check_result(test_case, code, data)
|
||||
|
|
|
@ -10,20 +10,20 @@ from comm.utils.readYaml import read_yaml_data
|
|||
from comm.unit.initializePremise import init_premise
|
||||
from comm.unit.apiSend import send_request
|
||||
from comm.unit.checkResult import check_result
|
||||
case_yaml = os.path.realpath(__file__).replace('testcase', 'page').replace('.py', '.yaml')
|
||||
case_path = os.path.dirname(case_yaml)
|
||||
case_dict = read_yaml_data(case_yaml)
|
||||
file_path = os.path.realpath(__file__).replace('\\', '/')
|
||||
case_yaml = file_path.replace('/testcase/', '/page/').replace('.py', '.yaml')
|
||||
test_case = read_yaml_data(case_yaml)
|
||||
|
||||
|
||||
@allure.feature(case_dict["test_info"]["title"])
|
||||
@allure.feature(test_case["test_info"]["title"])
|
||||
class TestRegister:
|
||||
|
||||
@pytest.mark.parametrize("case_data", case_dict["test_case"])
|
||||
@pytest.mark.parametrize("test_case", test_case["test_case"])
|
||||
@allure.story("test_getAdultCurbactList")
|
||||
def test_getAdultCurbactList(self, case_data):
|
||||
def test_getAdultCurbactList(self, test_case):
|
||||
# 初始化请求:执行前置接口+替换关联变量
|
||||
test_info, case_data = init_premise(case_dict["test_info"], case_data, case_path)
|
||||
test_info, test_case = init_premise(test_case["test_info"], test_case, case_yaml)
|
||||
# 发送当前接口
|
||||
code, data = send_request(test_info, case_data)
|
||||
code, data = send_request(test_info, test_case)
|
||||
# 校验接口返回
|
||||
check_result(case_data, code, data)
|
||||
check_result(test_case, code, data)
|
||||
|
|
|
@ -10,20 +10,20 @@ from comm.utils.readYaml import read_yaml_data
|
|||
from comm.unit.initializePremise import init_premise
|
||||
from comm.unit.apiSend import send_request
|
||||
from comm.unit.checkResult import check_result
|
||||
case_yaml = os.path.realpath(__file__).replace('testcase', 'page').replace('.py', '.yaml')
|
||||
case_path = os.path.dirname(case_yaml)
|
||||
case_dict = read_yaml_data(case_yaml)
|
||||
file_path = os.path.realpath(__file__).replace('\\', '/')
|
||||
case_yaml = file_path.replace('/testcase/', '/page/').replace('.py', '.yaml')
|
||||
test_case = read_yaml_data(case_yaml)
|
||||
|
||||
|
||||
@allure.feature(case_dict["test_info"]["title"])
|
||||
@allure.feature(test_case["test_info"]["title"])
|
||||
class TestRegister:
|
||||
|
||||
@pytest.mark.parametrize("case_data", case_dict["test_case"])
|
||||
@pytest.mark.parametrize("test_case", test_case["test_case"])
|
||||
@allure.story("test_initCanSelInfo")
|
||||
def test_initCanSelInfo(self, case_data):
|
||||
def test_initCanSelInfo(self, test_case):
|
||||
# 初始化请求:执行前置接口+替换关联变量
|
||||
test_info, case_data = init_premise(case_dict["test_info"], case_data, case_path)
|
||||
test_info, test_case = init_premise(test_case["test_info"], test_case, case_yaml)
|
||||
# 发送当前接口
|
||||
code, data = send_request(test_info, case_data)
|
||||
code, data = send_request(test_info, test_case)
|
||||
# 校验接口返回
|
||||
check_result(case_data, code, data)
|
||||
check_result(test_case, code, data)
|
||||
|
|
|
@ -30,7 +30,7 @@ def write_case(case_path, auto_yaml=True):
|
|||
# 遍历测试用例列表
|
||||
for yaml_file in yaml_list:
|
||||
test_data = read_yaml_data(yaml_file)
|
||||
test_script = yaml_file.replace('page', 'testcase').replace('.yaml', '.py')
|
||||
test_script = yaml_file.replace('\\', '/').replace('/page/', '/testcase/').replace('.yaml', '.py')
|
||||
# case_name = os.path.basename(test_script).replace('.py', '')
|
||||
case_path = os.path.dirname(test_script)
|
||||
# 判断文件路径是否存在
|
||||
|
|
|
@ -12,6 +12,128 @@ from comm.utils.readJson import write_json_file
|
|||
from config import API_CONFIG, PROJECT_NAME
|
||||
|
||||
|
||||
def init_api_conf(har_ct):
|
||||
host = har_ct["host"]
|
||||
port = har_ct["actualPort"]
|
||||
headers = har_ct["request"]["header"]['headers']
|
||||
# 定义项目api通过配置
|
||||
proj_conf = dict()
|
||||
proj_conf['timeout'] = 10
|
||||
proj_conf['scheme'] = har_ct["scheme"]
|
||||
proj_conf['host'] = host + ':' + str(port)
|
||||
simp_header = dict()
|
||||
for header in headers:
|
||||
# 去除基础请求头
|
||||
base_header = ['Host',
|
||||
'Content-Length',
|
||||
'User-Agent',
|
||||
'Origin',
|
||||
'Referer',
|
||||
'Connection',
|
||||
'Accept',
|
||||
'Accept-Encoding',
|
||||
'Accept-Language']
|
||||
if header['name'] not in base_header:
|
||||
simp_header[header['name']] = header['value']
|
||||
|
||||
# 判断是否存在自定义消息头
|
||||
if simp_header:
|
||||
proj_conf['headers'] = simp_header
|
||||
else:
|
||||
proj_conf['headers'] = None
|
||||
|
||||
# 检查是否已存在项目配置信息,没有则写入
|
||||
run_conf = read_yaml_data(API_CONFIG)
|
||||
if run_conf:
|
||||
if PROJECT_NAME not in run_conf:
|
||||
run_conf[PROJECT_NAME] = proj_conf
|
||||
write_yaml_file(API_CONFIG, run_conf)
|
||||
else:
|
||||
api_conf = dict()
|
||||
api_conf[PROJECT_NAME] = proj_conf
|
||||
write_yaml_file(API_CONFIG, api_conf)
|
||||
|
||||
|
||||
def parse_request_parameter(har_ct):
|
||||
# 解析请求报文
|
||||
parameter = dict()
|
||||
method = har_ct["method"]
|
||||
try:
|
||||
if method in 'POST':
|
||||
parameter_list = urllib.parse.unquote(har_ct["request"]["body"]["text"])
|
||||
elif method in 'PUT':
|
||||
parameter_list = har_ct["request"]["body"]["text"]
|
||||
elif method in 'DELETE':
|
||||
parameter_list = urllib.parse.unquote(har_ct["request"]["body"]["text"])
|
||||
else:
|
||||
parameter_list = har_ct["query"]
|
||||
|
||||
if parameter_list:
|
||||
if "&" in parameter_list:
|
||||
for key in parameter_list.split("&"):
|
||||
val = key.split("=")
|
||||
parameter[val[0]] = val[1]
|
||||
else:
|
||||
parameter = json.loads(parameter_list)
|
||||
else:
|
||||
parameter = None
|
||||
return parameter
|
||||
|
||||
except Exception as e:
|
||||
logging.error("未找到parameter: %s" % e)
|
||||
raise e
|
||||
|
||||
|
||||
def init_test_case(har_ct, module_path, parameter, file_name):
|
||||
# path = har_ct["path"]
|
||||
# title = path.split("/")[-1].replace('-', '')
|
||||
title = file_name
|
||||
# 定义测试用例
|
||||
test_case = dict()
|
||||
test_case["summary"] = title
|
||||
test_case["describe"] = 'test_' + title
|
||||
|
||||
# 定义请求入参信息,且当参数字符总长度大于200时单独写入json文件
|
||||
if len(str(parameter)) > 200:
|
||||
param_name = title + '_request.json'
|
||||
if param_name not in os.listdir(module_path):
|
||||
# 定义请求json
|
||||
param_dict = dict()
|
||||
param_dict["summary"] = title
|
||||
param_dict["body"] = parameter
|
||||
param_file = module_path + '/' + param_name
|
||||
logging.info("生成请求文件: {}".format(param_file))
|
||||
write_json_file(param_file, [param_dict])
|
||||
test_case["parameter"] = param_name
|
||||
else:
|
||||
test_case["parameter"] = parameter
|
||||
|
||||
# 定义请求返回信息
|
||||
response_code = har_ct["response"]["status"]
|
||||
response_body = har_ct["response"]["body"]["text"]
|
||||
check = dict()
|
||||
check["check_type"] = 'check_json'
|
||||
check["expected_code"] = response_code
|
||||
expected_request = json.loads(response_body)
|
||||
|
||||
# 当返回参数字符总长度大于200时单独写入json文件
|
||||
if len(str(expected_request)) > 200:
|
||||
result_name = title + '_response.json'
|
||||
if result_name not in os.listdir(module_path):
|
||||
# 定义响应json
|
||||
result_dict = dict()
|
||||
result_dict["summary"] = title
|
||||
result_dict["body"] = expected_request
|
||||
result_file = module_path + '/' + result_name
|
||||
logging.info("生成响应文件: {}".format(result_file))
|
||||
write_json_file(result_file, [result_dict])
|
||||
check["expected_result"] = result_name
|
||||
else:
|
||||
check["expected_result"] = expected_request
|
||||
test_case["check_body"] = check
|
||||
return test_case
|
||||
|
||||
|
||||
def write_case_yaml(har_path):
|
||||
"""循环读取接口数据文件
|
||||
|
||||
|
@ -22,7 +144,8 @@ def write_case_yaml(har_path):
|
|||
logging.info("读取抓包文件主目录: {}".format(har_path))
|
||||
har_list = os.listdir(har_path)
|
||||
for each in har_list:
|
||||
ext_name = os.path.splitext(each)[1]
|
||||
# ext_name = os.path.splitext(each)[1]
|
||||
file_name, ext_name = os.path.splitext(each)
|
||||
if ext_name == '.chlsj':
|
||||
|
||||
logging.info("读取抓包文件: {}".format(each))
|
||||
|
@ -32,146 +155,46 @@ def write_case_yaml(har_path):
|
|||
har_ct = har_cts[0]
|
||||
|
||||
# 获取接口基本信息
|
||||
host = har_ct["host"]
|
||||
port = har_ct["actualPort"]
|
||||
method = har_ct["method"]
|
||||
path = har_ct["path"]
|
||||
headers = har_ct["request"]["header"]['headers']
|
||||
title = path.split("/")[-1].replace('-', '')
|
||||
title = file_name
|
||||
# title = path.split("/")[-1].replace('-', '')
|
||||
module = path.split("/")[-2].replace('-', '')
|
||||
module_path = har_path.split('data')[0] + '/page/' + module
|
||||
|
||||
# 创建模块目录
|
||||
module_path = har_path.split('data')[0] + '/page/' + module
|
||||
try:
|
||||
os.makedirs(module_path)
|
||||
except:
|
||||
pass
|
||||
|
||||
# 定义api通过配置
|
||||
api_config = dict()
|
||||
api_config['cookies'] = None
|
||||
api_config['scheme'] = har_ct["scheme"]
|
||||
api_config['host'] = host + ':' + str(port)
|
||||
simp_header = dict()
|
||||
for header in headers:
|
||||
# 去除基础请求头
|
||||
base_header = ['Host',
|
||||
'Content-Length',
|
||||
'User-Agent',
|
||||
'Origin',
|
||||
'Referer',
|
||||
'Connection',
|
||||
'Accept',
|
||||
'Accept-Encoding',
|
||||
'Accept-Language']
|
||||
if header['name'] not in base_header:
|
||||
simp_header[header['name']] = header['value']
|
||||
# 判断是否存在自定义消息头
|
||||
if simp_header:
|
||||
api_config['headers'] = simp_header
|
||||
else:
|
||||
api_config['headers'] = None
|
||||
# 检查是否已存在项目配置信息,没有则写入
|
||||
rconfig = read_yaml_data(API_CONFIG)
|
||||
if rconfig:
|
||||
if PROJECT_NAME not in rconfig:
|
||||
rconfig[PROJECT_NAME] = api_config
|
||||
write_yaml_file(API_CONFIG, rconfig)
|
||||
else:
|
||||
nconfig = dict()
|
||||
nconfig[PROJECT_NAME] = api_config
|
||||
write_yaml_file(API_CONFIG, nconfig)
|
||||
# 初始化api配置
|
||||
init_api_conf(har_ct)
|
||||
|
||||
# 解析请求参数
|
||||
parameter = parse_request_parameter(har_ct)
|
||||
|
||||
# 初始化测试用例
|
||||
test_case = init_test_case(har_ct, module_path, parameter, file_name)
|
||||
|
||||
# 定义测试信息
|
||||
test_info = dict()
|
||||
test_info["title"] = module
|
||||
test_info["host"] = '${host}'
|
||||
test_info["scheme"] = '${scheme}' # har_ct["scheme"]
|
||||
test_info["scheme"] = '${scheme}'
|
||||
test_info["method"] = method
|
||||
test_info["address"] = path
|
||||
test_info["mime_type"] = har_ct["request"]["mimeType"]
|
||||
test_info["headers"] = '${headers}'
|
||||
test_info["timeout"] = 10
|
||||
test_info["timeout"] = '${timeout}'
|
||||
test_info["file"] = False
|
||||
test_info["cookies"] = False
|
||||
test_info["premise"] = False
|
||||
|
||||
# 解析请求报文
|
||||
parameter = dict()
|
||||
try:
|
||||
if method in 'POST':
|
||||
parameter_list = urllib.parse.unquote(har_ct["request"]["body"]["text"])
|
||||
elif method in 'PUT':
|
||||
parameter_list = har_ct["request"]["body"]["text"]
|
||||
elif method in 'DELETE':
|
||||
parameter_list = urllib.parse.unquote(har_ct["request"]["body"]["text"])
|
||||
else:
|
||||
parameter_list = har_ct["query"]
|
||||
|
||||
if parameter_list:
|
||||
if "&" in parameter_list:
|
||||
for key in parameter_list.split("&"):
|
||||
val = key.split("=")
|
||||
parameter[val[0]] = val[1]
|
||||
else:
|
||||
parameter = json.loads(parameter_list)
|
||||
else:
|
||||
parameter = None
|
||||
|
||||
except Exception as e:
|
||||
logging.error("未找到parameter: %s" % e)
|
||||
raise e
|
||||
|
||||
# 定义用例信息
|
||||
test_case_list = list()
|
||||
test_case = dict()
|
||||
test_case["summary"] = title
|
||||
test_case["describe"] = 'test_'+title
|
||||
|
||||
# 定义请求入参信息,且当参数字符总长度大于200时单独写入json文件
|
||||
if len(str(parameter)) > 200:
|
||||
param_name = title+'_request.json'
|
||||
if param_name not in os.listdir(module_path):
|
||||
# 定义请求json
|
||||
param_dict = dict()
|
||||
param_dict["summary"] = title
|
||||
param_dict["body"] = parameter
|
||||
param_file = module_path+'/'+param_name
|
||||
logging.info("生成请求文件: {}".format(param_file))
|
||||
write_json_file(param_file, [param_dict])
|
||||
test_case["parameter"] = param_name
|
||||
else:
|
||||
test_case["parameter"] = parameter
|
||||
|
||||
# 定义请求返回信息
|
||||
response_code = har_ct["response"]["status"]
|
||||
response_body = har_ct["response"]["body"]["text"]
|
||||
check = dict()
|
||||
check["check_type"] = 'check_json'
|
||||
check["expected_code"] = response_code
|
||||
expected_request = json.loads(response_body)
|
||||
|
||||
# 当返回参数字符总长度大于200时单独写入json文件
|
||||
if len(str(expected_request)) > 200:
|
||||
result_name = title+'_response.json'
|
||||
if result_name not in os.listdir(module_path):
|
||||
# 定义响应json
|
||||
result_dict = dict()
|
||||
result_dict["summary"] = title
|
||||
result_dict["body"] = expected_request
|
||||
result_file = module_path + '/' + result_name
|
||||
logging.info("生成响应文件: {}".format(result_file))
|
||||
write_json_file(result_file, [result_dict])
|
||||
check["expected_result"] = result_name
|
||||
else:
|
||||
check["expected_result"] = expected_request
|
||||
test_case["check_body"] = check
|
||||
test_case_list.append(test_case)
|
||||
|
||||
# 合并测试信息、用例信息
|
||||
# 合并测试信息、测试用例
|
||||
case_list = dict()
|
||||
case_list["test_info"] = test_info
|
||||
case_list["test_case"] = test_case_list
|
||||
case_list["test_case"] = [test_case]
|
||||
|
||||
# 写入测试用例(存在则忽略)
|
||||
case_name = 'test_'+title+'.yaml'
|
||||
|
|
|
@ -205,9 +205,9 @@ def check_result(case_data, code, data):
|
|||
from comm.unit import queryDatabase as qdb
|
||||
check_db = case_data['check_db']
|
||||
# 获取数据库期望结果:获取期望结果-获取关联值-替换关联值
|
||||
data['parameter'] = case_data['parameter']
|
||||
__relevance = readRelevance.get_relevance(data, check_db)
|
||||
check_db = replaceRelevance.replace(check_db, __relevance)
|
||||
# data['parameter'] = case_data['parameter']
|
||||
relevance = readRelevance.get_relevance(data, check_db)
|
||||
check_db = replaceRelevance.replace(check_db, relevance)
|
||||
|
||||
# 循环校验数据库
|
||||
for each in check_db:
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
PyDemo:
|
||||
# 首次会根据接口数据包生成,可自行更改或添加新配置,所有配置将用于公共关联值。
|
||||
host: 10.88.88.141:20037
|
||||
timeout: 10
|
||||
scheme: http
|
||||
host: 127.0.0.1:20037
|
||||
headers:
|
||||
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
|
||||
cookies:
|
||||
headtoken: xu5YwIZFkVGczMn0H0rot2ps7zRIbvrTHNwMXx1sJXg=
|
||||
|
|
|
@ -3,18 +3,18 @@ PyDemo:
|
|||
timeout: 3
|
||||
# MySQL配置信息
|
||||
mysql_info:
|
||||
address: 10.88.88.88:3160
|
||||
address: 127.0.0.1:3160
|
||||
db: test
|
||||
user: test
|
||||
auth: test
|
||||
# HBase配置信息(需要启动phoenix查询服务)
|
||||
hbase_info:
|
||||
address: 10.88.88.88:8765
|
||||
address: 127.0.0.1:8765
|
||||
db: test
|
||||
# ES配置信息(需要开放http查询服务)
|
||||
es_info:
|
||||
address: 10.88.88.88:9200
|
||||
address: 127.0.0.1:9200
|
||||
db: test
|
||||
# Solr配置信息
|
||||
solr_info:
|
||||
address: 10.88.88.88:8883
|
||||
address: 127.0.0.1:8883
|
||||
|
|
|
@ -10,20 +10,20 @@ from comm.utils.readYaml import read_yaml_data
|
|||
from comm.unit.initializePremise import init_premise
|
||||
from comm.unit.apiSend import send_request
|
||||
from comm.unit.checkResult import check_result
|
||||
case_yaml = os.path.realpath(__file__).replace('testcase', 'page').replace('.py', '.yaml')
|
||||
case_path = os.path.dirname(case_yaml)
|
||||
case_dict = read_yaml_data(case_yaml)
|
||||
file_path = os.path.realpath(__file__).replace('\\', '/')
|
||||
case_yaml = file_path.replace('/testcase/', '/page/').replace('.py', '.yaml')
|
||||
case_data = read_yaml_data(case_yaml)
|
||||
|
||||
|
||||
@allure.feature(case_dict["test_info"]["title"])
|
||||
@allure.feature(case_data["test_info"]["title"])
|
||||
class TestTemplate:
|
||||
|
||||
@pytest.mark.parametrize("case_data", case_dict["test_case"])
|
||||
@pytest.mark.parametrize("test_case", case_data["test_case"])
|
||||
@allure.story("test_template")
|
||||
def test_template(self, case_data):
|
||||
def test_template(self, test_case):
|
||||
# 初始化请求:执行前置接口+替换关联变量
|
||||
test_info, case_data = init_premise(case_dict["test_info"], case_data, case_path)
|
||||
test_info, test_case = init_premise(case_data["test_info"], test_case, case_yaml)
|
||||
# 发送当前接口
|
||||
code, data = send_request(test_info, case_data)
|
||||
code, data = send_request(test_info, test_case)
|
||||
# 校验接口返回
|
||||
check_result(case_data, code, data)
|
||||
check_result(test_case, code, data)
|
||||
|
|
|
@ -42,7 +42,8 @@ if __name__ == '__main__':
|
|||
'--reruns', str(RC['reruns']),
|
||||
'--maxfail', str(RC['maxfail']),
|
||||
'--alluredir', REPORT_DIR+'/xml',
|
||||
'--clean-alluredir']
|
||||
'--clean-alluredir',
|
||||
'--disable-warnings']
|
||||
# 判断是否开启用例匹配
|
||||
if RC['pattern']:
|
||||
args_list += ['-k ' + str(RC['pattern'])]
|
||||
|
|
Loading…
Reference in New Issue