Merge branch 'dev'

This commit is contained in:
Leozhanggg 2021-11-06 11:56:30 +08:00
commit cb572da6c8
23 changed files with 224 additions and 196 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*.xml
*.pyc

File diff suppressed because one or more lines are too long

View File

@ -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"}}}]

View File

@ -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

View File

@ -1,12 +1,12 @@
test_info: test_info:
title: perRelated title: perRelated
host: ${host} host: ${host}
scheme: http scheme: ${scheme}
method: POST method: POST
address: /api/perRelated/addAudltCard address: /api/perRelated/addAudltCard
mime_type: application/x-www-form-urlencoded mime_type: application/x-www-form-urlencoded
headers: ${headers} headers: ${headers}
timeout: 10 timeout: ${timeout}
file: false file: false
cookies: false cookies: false
premise: false premise: false

View File

@ -1,12 +1,12 @@
test_info: test_info:
title: register title: register
host: ${host} host: ${host}
scheme: http scheme: ${scheme}
method: POST method: POST
address: /api/register/addOrUpCurBact address: /api/register/addOrUpCurBact
mime_type: application/x-www-form-urlencoded mime_type: application/x-www-form-urlencoded
headers: ${headers} headers: ${headers}
timeout: 10 timeout: ${timeout}
file: false file: false
cookies: false cookies: false
premise: /register/test_getAdultCurbactList.yaml premise: /register/test_getAdultCurbactList.yaml

View File

@ -1,12 +1,12 @@
test_info: test_info:
title: register title: register
host: ${host} host: ${host}
scheme: http scheme: ${scheme}
method: POST method: POST
address: /api/register/findParam address: /api/register/findParam
mime_type: application/x-www-form-urlencoded mime_type: application/x-www-form-urlencoded
headers: ${headers} headers: ${headers}
timeout: 10 timeout: ${timeout}
file: false file: false
cookies: false cookies: false
premise: false premise: false

View File

@ -1,12 +1,12 @@
test_info: test_info:
title: register title: register
host: ${host} host: ${host}
scheme: http scheme: ${scheme}
method: POST method: POST
address: /api/register/getAdultCurbactList address: /api/register/getAdultCurbactList
mime_type: application/x-www-form-urlencoded mime_type: application/x-www-form-urlencoded
headers: ${headers} headers: ${headers}
timeout: 10 timeout: ${timeout}
file: false file: false
cookies: false cookies: false
premise: false premise: false

View File

@ -1,12 +1,12 @@
test_info: test_info:
title: register title: register
host: ${host} host: ${host}
scheme: http scheme: ${scheme}
method: POST method: POST
address: /api/register/initCanSelInfo address: /api/register/initCanSelInfo
mime_type: application/x-www-form-urlencoded mime_type: application/x-www-form-urlencoded
headers: ${headers} headers: ${headers}
timeout: 10 timeout: ${timeout}
file: false file: false
cookies: false cookies: false
premise: false premise: false

View File

@ -10,20 +10,20 @@ from comm.utils.readYaml import read_yaml_data
from comm.unit.initializePremise import init_premise from comm.unit.initializePremise import init_premise
from comm.unit.apiSend import send_request from comm.unit.apiSend import send_request
from comm.unit.checkResult import check_result from comm.unit.checkResult import check_result
case_yaml = os.path.realpath(__file__).replace('testcase', 'page').replace('.py', '.yaml') file_path = os.path.realpath(__file__).replace('\\', '/')
case_path = os.path.dirname(case_yaml) case_yaml = file_path.replace('/testcase/', '/page/').replace('.py', '.yaml')
case_dict = read_yaml_data(case_yaml) test_case = read_yaml_data(case_yaml)
@allure.feature(case_dict["test_info"]["title"]) @allure.feature(test_case["test_info"]["title"])
class TestPerrelated: class TestPerrelated:
@pytest.mark.parametrize("case_data", case_dict["test_case"]) @pytest.mark.parametrize("test_case", test_case["test_case"])
@allure.story("test_addAudltCard") @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)

View File

@ -10,20 +10,20 @@ from comm.utils.readYaml import read_yaml_data
from comm.unit.initializePremise import init_premise from comm.unit.initializePremise import init_premise
from comm.unit.apiSend import send_request from comm.unit.apiSend import send_request
from comm.unit.checkResult import check_result from comm.unit.checkResult import check_result
case_yaml = os.path.realpath(__file__).replace('testcase', 'page').replace('.py', '.yaml') file_path = os.path.realpath(__file__).replace('\\', '/')
case_path = os.path.dirname(case_yaml) case_yaml = file_path.replace('/testcase/', '/page/').replace('.py', '.yaml')
case_dict = read_yaml_data(case_yaml) case_data = read_yaml_data(case_yaml)
@allure.feature(case_dict["test_info"]["title"]) @allure.feature(case_data["test_info"]["title"])
class TestRegister: class TestRegister:
@pytest.mark.parametrize("case_data", case_dict["test_case"]) @pytest.mark.parametrize("test_case", case_data["test_case"])
@allure.story("test_addOrUpCurBact") @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)

View File

@ -10,20 +10,20 @@ from comm.utils.readYaml import read_yaml_data
from comm.unit.initializePremise import init_premise from comm.unit.initializePremise import init_premise
from comm.unit.apiSend import send_request from comm.unit.apiSend import send_request
from comm.unit.checkResult import check_result from comm.unit.checkResult import check_result
case_yaml = os.path.realpath(__file__).replace('testcase', 'page').replace('.py', '.yaml') file_path = os.path.realpath(__file__).replace('\\', '/')
case_path = os.path.dirname(case_yaml) case_yaml = file_path.replace('/testcase/', '/page/').replace('.py', '.yaml')
case_dict = read_yaml_data(case_yaml) test_case = read_yaml_data(case_yaml)
@allure.feature(case_dict["test_info"]["title"]) @allure.feature(test_case["test_info"]["title"])
class TestRegister: class TestRegister:
@pytest.mark.parametrize("case_data", case_dict["test_case"]) @pytest.mark.parametrize("test_case", test_case["test_case"])
@allure.story("test_findParam") @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)

View File

@ -10,20 +10,20 @@ from comm.utils.readYaml import read_yaml_data
from comm.unit.initializePremise import init_premise from comm.unit.initializePremise import init_premise
from comm.unit.apiSend import send_request from comm.unit.apiSend import send_request
from comm.unit.checkResult import check_result from comm.unit.checkResult import check_result
case_yaml = os.path.realpath(__file__).replace('testcase', 'page').replace('.py', '.yaml') file_path = os.path.realpath(__file__).replace('\\', '/')
case_path = os.path.dirname(case_yaml) case_yaml = file_path.replace('/testcase/', '/page/').replace('.py', '.yaml')
case_dict = read_yaml_data(case_yaml) test_case = read_yaml_data(case_yaml)
@allure.feature(case_dict["test_info"]["title"]) @allure.feature(test_case["test_info"]["title"])
class TestRegister: class TestRegister:
@pytest.mark.parametrize("case_data", case_dict["test_case"]) @pytest.mark.parametrize("test_case", test_case["test_case"])
@allure.story("test_getAdultCurbactList") @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)

View File

@ -10,20 +10,20 @@ from comm.utils.readYaml import read_yaml_data
from comm.unit.initializePremise import init_premise from comm.unit.initializePremise import init_premise
from comm.unit.apiSend import send_request from comm.unit.apiSend import send_request
from comm.unit.checkResult import check_result from comm.unit.checkResult import check_result
case_yaml = os.path.realpath(__file__).replace('testcase', 'page').replace('.py', '.yaml') file_path = os.path.realpath(__file__).replace('\\', '/')
case_path = os.path.dirname(case_yaml) case_yaml = file_path.replace('/testcase/', '/page/').replace('.py', '.yaml')
case_dict = read_yaml_data(case_yaml) test_case = read_yaml_data(case_yaml)
@allure.feature(case_dict["test_info"]["title"]) @allure.feature(test_case["test_info"]["title"])
class TestRegister: class TestRegister:
@pytest.mark.parametrize("case_data", case_dict["test_case"]) @pytest.mark.parametrize("test_case", test_case["test_case"])
@allure.story("test_initCanSelInfo") @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)

View File

@ -30,7 +30,7 @@ def write_case(case_path, auto_yaml=True):
# 遍历测试用例列表 # 遍历测试用例列表
for yaml_file in yaml_list: for yaml_file in yaml_list:
test_data = read_yaml_data(yaml_file) 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_name = os.path.basename(test_script).replace('.py', '')
case_path = os.path.dirname(test_script) case_path = os.path.dirname(test_script)
# 判断文件路径是否存在 # 判断文件路径是否存在

View File

@ -12,46 +12,15 @@ from comm.utils.readJson import write_json_file
from config import API_CONFIG, PROJECT_NAME from config import API_CONFIG, PROJECT_NAME
def write_case_yaml(har_path): def init_api_conf(har_ct):
"""循环读取接口数据文件
:param har_path: Charles导出文件路径
:return:
"""
case_file_list = list()
logging.info("读取抓包文件主目录: {}".format(har_path))
har_list = os.listdir(har_path)
for each in har_list:
ext_name = os.path.splitext(each)[1]
if ext_name == '.chlsj':
logging.info("读取抓包文件: {}".format(each))
file_path = har_path+'/'+each
with open(file_path, 'r', encoding='utf-8') as f:
har_cts = json.loads(f.read())
har_ct = har_cts[0]
# 获取接口基本信息
host = har_ct["host"] host = har_ct["host"]
port = har_ct["actualPort"] port = har_ct["actualPort"]
method = har_ct["method"]
path = har_ct["path"]
headers = har_ct["request"]["header"]['headers'] headers = har_ct["request"]["header"]['headers']
title = path.split("/")[-1].replace('-', '') # 定义项目api通过配置
module = path.split("/")[-2].replace('-', '') proj_conf = dict()
proj_conf['timeout'] = 10
# 创建模块目录 proj_conf['scheme'] = har_ct["scheme"]
module_path = har_path.split('data')[0] + '/page/' + module proj_conf['host'] = host + ':' + str(port)
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() simp_header = dict()
for header in headers: for header in headers:
# 去除基础请求头 # 去除基础请求头
@ -66,38 +35,29 @@ def write_case_yaml(har_path):
'Accept-Language'] 'Accept-Language']
if header['name'] not in base_header: if header['name'] not in base_header:
simp_header[header['name']] = header['value'] simp_header[header['name']] = header['value']
# 判断是否存在自定义消息头 # 判断是否存在自定义消息头
if simp_header: if simp_header:
api_config['headers'] = simp_header proj_conf['headers'] = simp_header
else: else:
api_config['headers'] = None proj_conf['headers'] = None
# 检查是否已存在项目配置信息,没有则写入 # 检查是否已存在项目配置信息,没有则写入
rconfig = read_yaml_data(API_CONFIG) run_conf = read_yaml_data(API_CONFIG)
if rconfig: if run_conf:
if PROJECT_NAME not in rconfig: if PROJECT_NAME not in run_conf:
rconfig[PROJECT_NAME] = api_config run_conf[PROJECT_NAME] = proj_conf
write_yaml_file(API_CONFIG, rconfig) write_yaml_file(API_CONFIG, run_conf)
else: else:
nconfig = dict() api_conf = dict()
nconfig[PROJECT_NAME] = api_config api_conf[PROJECT_NAME] = proj_conf
write_yaml_file(API_CONFIG, nconfig) write_yaml_file(API_CONFIG, api_conf)
# 定义测试信息
test_info = dict()
test_info["title"] = module
test_info["host"] = '${host}'
test_info["scheme"] = '${scheme}' # har_ct["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["file"] = False
test_info["cookies"] = False
test_info["premise"] = False
def parse_request_parameter(har_ct):
# 解析请求报文 # 解析请求报文
parameter = dict() parameter = dict()
method = har_ct["method"]
try: try:
if method in 'POST': if method in 'POST':
parameter_list = urllib.parse.unquote(har_ct["request"]["body"]["text"]) parameter_list = urllib.parse.unquote(har_ct["request"]["body"]["text"])
@ -117,13 +77,18 @@ def write_case_yaml(har_path):
parameter = json.loads(parameter_list) parameter = json.loads(parameter_list)
else: else:
parameter = None parameter = None
return parameter
except Exception as e: except Exception as e:
logging.error("未找到parameter: %s" % e) logging.error("未找到parameter: %s" % e)
raise e raise e
# 定义用例信息
test_case_list = list() 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 = dict()
test_case["summary"] = title test_case["summary"] = title
test_case["describe"] = 'test_' + title test_case["describe"] = 'test_' + title
@ -166,12 +131,70 @@ def write_case_yaml(har_path):
else: else:
check["expected_result"] = expected_request check["expected_result"] = expected_request
test_case["check_body"] = check test_case["check_body"] = check
test_case_list.append(test_case) return test_case
# 合并测试信息、用例信息
def write_case_yaml(har_path):
"""循环读取接口数据文件
:param har_path: Charles导出文件路径
:return:
"""
case_file_list = list()
logging.info("读取抓包文件主目录: {}".format(har_path))
har_list = os.listdir(har_path)
for each in har_list:
# ext_name = os.path.splitext(each)[1]
file_name, ext_name = os.path.splitext(each)
if ext_name == '.chlsj':
logging.info("读取抓包文件: {}".format(each))
file_path = har_path+'/'+each
with open(file_path, 'r', encoding='utf-8') as f:
har_cts = json.loads(f.read())
har_ct = har_cts[0]
# 获取接口基本信息
method = har_ct["method"]
path = har_ct["path"]
title = file_name
# title = path.split("/")[-1].replace('-', '')
module = path.split("/")[-2].replace('-', '')
module_path = har_path.split('data')[0] + '/page/' + module
# 创建模块目录
try:
os.makedirs(module_path)
except:
pass
# 初始化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}'
test_info["method"] = method
test_info["address"] = path
test_info["mime_type"] = har_ct["request"]["mimeType"]
test_info["headers"] = '${headers}'
test_info["timeout"] = '${timeout}'
test_info["file"] = False
test_info["cookies"] = False
test_info["premise"] = False
# 合并测试信息、测试用例
case_list = dict() case_list = dict()
case_list["test_info"] = test_info case_list["test_info"] = test_info
case_list["test_case"] = test_case_list case_list["test_case"] = [test_case]
# 写入测试用例(存在则忽略) # 写入测试用例(存在则忽略)
case_name = 'test_'+title+'.yaml' case_name = 'test_'+title+'.yaml'

View File

@ -205,9 +205,9 @@ def check_result(case_data, code, data):
from comm.unit import queryDatabase as qdb from comm.unit import queryDatabase as qdb
check_db = case_data['check_db'] check_db = case_data['check_db']
# 获取数据库期望结果:获取期望结果-获取关联值-替换关联值 # 获取数据库期望结果:获取期望结果-获取关联值-替换关联值
data['parameter'] = case_data['parameter'] # data['parameter'] = case_data['parameter']
__relevance = readRelevance.get_relevance(data, check_db) relevance = readRelevance.get_relevance(data, check_db)
check_db = replaceRelevance.replace(check_db, __relevance) check_db = replaceRelevance.replace(check_db, relevance)
# 循环校验数据库 # 循环校验数据库
for each in check_db: for each in check_db:

View File

@ -1,7 +1,8 @@
PyDemo: PyDemo:
# 首次会根据接口数据包生成,可自行更改或添加新配置,所有配置将用于公共关联值。 # 首次会根据接口数据包生成,可自行更改或添加新配置,所有配置将用于公共关联值。
host: 10.88.88.141:20037 timeout: 10
scheme: http
host: 127.0.0.1:20037
headers: headers:
Content-Type: application/x-www-form-urlencoded;charset=UTF-8 Content-Type: application/x-www-form-urlencoded;charset=UTF-8
cookies:
headtoken: xu5YwIZFkVGczMn0H0rot2ps7zRIbvrTHNwMXx1sJXg= headtoken: xu5YwIZFkVGczMn0H0rot2ps7zRIbvrTHNwMXx1sJXg=

View File

@ -3,18 +3,18 @@ PyDemo:
timeout: 3 timeout: 3
# MySQL配置信息 # MySQL配置信息
mysql_info: mysql_info:
address: 10.88.88.88:3160 address: 127.0.0.1:3160
db: test db: test
user: test user: test
auth: test auth: test
# HBase配置信息(需要启动phoenix查询服务) # HBase配置信息(需要启动phoenix查询服务)
hbase_info: hbase_info:
address: 10.88.88.88:8765 address: 127.0.0.1:8765
db: test db: test
# ES配置信息(需要开放http查询服务) # ES配置信息(需要开放http查询服务)
es_info: es_info:
address: 10.88.88.88:9200 address: 127.0.0.1:9200
db: test db: test
# Solr配置信息 # Solr配置信息
solr_info: solr_info:
address: 10.88.88.88:8883 address: 127.0.0.1:8883

View File

@ -10,20 +10,20 @@ from comm.utils.readYaml import read_yaml_data
from comm.unit.initializePremise import init_premise from comm.unit.initializePremise import init_premise
from comm.unit.apiSend import send_request from comm.unit.apiSend import send_request
from comm.unit.checkResult import check_result from comm.unit.checkResult import check_result
case_yaml = os.path.realpath(__file__).replace('testcase', 'page').replace('.py', '.yaml') file_path = os.path.realpath(__file__).replace('\\', '/')
case_path = os.path.dirname(case_yaml) case_yaml = file_path.replace('/testcase/', '/page/').replace('.py', '.yaml')
case_dict = read_yaml_data(case_yaml) case_data = read_yaml_data(case_yaml)
@allure.feature(case_dict["test_info"]["title"]) @allure.feature(case_data["test_info"]["title"])
class TestTemplate: class TestTemplate:
@pytest.mark.parametrize("case_data", case_dict["test_case"]) @pytest.mark.parametrize("test_case", case_data["test_case"])
@allure.story("test_template") @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)

View File

@ -42,7 +42,8 @@ if __name__ == '__main__':
'--reruns', str(RC['reruns']), '--reruns', str(RC['reruns']),
'--maxfail', str(RC['maxfail']), '--maxfail', str(RC['maxfail']),
'--alluredir', REPORT_DIR+'/xml', '--alluredir', REPORT_DIR+'/xml',
'--clean-alluredir'] '--clean-alluredir',
'--disable-warnings']
# 判断是否开启用例匹配 # 判断是否开启用例匹配
if RC['pattern']: if RC['pattern']:
args_list += ['-k ' + str(RC['pattern'])] args_list += ['-k ' + str(RC['pattern'])]