mirror of https://gitee.com/a529548204/apitest.git
结构大改 还没完成, 当前版本暂时无法使用
This commit is contained in:
parent
235339e8b0
commit
d44d4465a7
|
@ -6,10 +6,10 @@ import random
|
|||
import allure
|
||||
import requests
|
||||
from requests_toolbelt import MultipartEncoder
|
||||
from scripts.log import Log
|
||||
from scripts.randomData import replace_random
|
||||
from util.tools.log import Log
|
||||
from util.tools.randomData import replace_random
|
||||
from config.confManage import host_manage
|
||||
from scripts.relevance import Relevance
|
||||
from util.tools.relevance import Cache
|
||||
|
||||
Log()
|
||||
|
||||
|
@ -18,7 +18,7 @@ class apiSend(object):
|
|||
|
||||
def __init__(self):
|
||||
self.http_type = host_manage(hos="${http_type}$")
|
||||
self.rel = Relevance()
|
||||
self.rel = Cache()
|
||||
|
||||
@staticmethod
|
||||
def iniDatas(data):
|
||||
|
|
|
@ -5,10 +5,10 @@ import logging
|
|||
import allure
|
||||
import jsonpath
|
||||
|
||||
from scripts.dataBase import MYSQL
|
||||
from scripts.log import Log
|
||||
from scripts.randomData import replace_random
|
||||
from scripts.readYamlFile import ini_yaml
|
||||
from util.tools.dataBase import MYSQL
|
||||
from util.tools.log import Log
|
||||
from util.tools.randomData import replace_random
|
||||
from util.tools.readYamlFile import ini_yaml
|
||||
|
||||
Log()
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# coding:utf-8
|
||||
import logging
|
||||
from scripts.log import Log
|
||||
from util.tools.log import Log
|
||||
Log()
|
||||
|
||||
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
# coding:utf-8
|
||||
import os
|
||||
|
||||
import yaml
|
||||
|
||||
from config.confManage import dir_manage
|
||||
from scripts import root_path
|
||||
|
||||
datapath = root_path + dir_manage("${test_suite}$") + dir_manage("${data_dir}$") + "/" + dir_manage("${test_name}$")
|
||||
|
||||
|
||||
def ini_yaml(filename, path=datapath):
|
||||
try:
|
||||
with open(path + "/" + filename, 'r', encoding="utf-8") as f:
|
||||
file_data = f.read()
|
||||
data = yaml.safe_load(file_data)
|
||||
|
||||
return data
|
||||
except UnicodeDecodeError:
|
||||
with open(path + "/" + filename, 'r') as f:
|
||||
file_data = f.read()
|
||||
data = yaml.safe_load(file_data)
|
||||
|
||||
return data
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(datapath)
|
||||
# get_yaml_data(r"F:\api2.0\config\runConfig.yml")
|
||||
runConfig_dict = ini_yaml(r'te.yml',r"D:\apitest\test_suite\datas\saasWeb\firmware")
|
||||
print(runConfig_dict)
|
||||
# # case_level = runConfig_dict[0]["address"].format(**{"home_id": "123"})
|
||||
# print(runConfig_dict)
|
||||
|
||||
# print(case_level)
|
||||
# print(type(case_level))
|
25
setupMain.py
25
setupMain.py
|
@ -6,9 +6,9 @@ import time
|
|||
import pytest
|
||||
|
||||
from config.confManage import dir_manage
|
||||
from scripts.dingding import DingTalkSendMsg
|
||||
from scripts.mkDir import mk_dir
|
||||
from scripts import root_path
|
||||
from util.tools.dingding import DingTalkSendMsg
|
||||
from util.tools.mkDir import mk_dir
|
||||
from util.tools import root_path
|
||||
|
||||
project_path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
@ -32,18 +32,9 @@ def run():
|
|||
mk_dir(temp_path)
|
||||
mk_dir(html_path)
|
||||
# 执行命令行
|
||||
logging.info(r"""
|
||||
██ ██ ██
|
||||
██████ ░░ ░██ ░██
|
||||
██████ ░██░░░██ ██ ██████ █████ ██████ ██████
|
||||
░░░░░░██ ░██ ░██░██░░░██░ ██░░░██ ██░░░░ ░░░██░
|
||||
███████ ░██████ ░██ ░██ ░███████░░█████ ░██
|
||||
██░░░░██ ░██░░░ ░██ ░██ ░██░░░░ ░░░░░██ ░██
|
||||
░░████████░██ ░██ ░░██ ░░██████ ██████ ░░██
|
||||
░░░░░░░░ ░░ ░░ ░░ ░░░░░░ ░░░░░░ ░░
|
||||
""")
|
||||
args = ['-s', '-q', test_case_path, '--alluredir', temp_path,"--clean-alluredir"]
|
||||
# args = ['-s', '-q', test_case_path,]
|
||||
|
||||
# args = ['-s', '-q', test_case_path, '--alluredir', temp_path,"--clean-alluredir"]
|
||||
args = ['-s', '-q', test_case_path,]
|
||||
|
||||
# args = ['-s', '-q', test_case_path, '--alluredir',
|
||||
# '/var/jenkins_home/workspace/js/report/xml'] # docker中 jenkins工作空间项目根路径
|
||||
|
@ -58,9 +49,9 @@ def run():
|
|||
# ding = DingTalkSendMsg()
|
||||
# ding.send_text("点击链接打开测试报告 http://192.168.1.2:9999",[13688400244])
|
||||
# 生成html报告
|
||||
os.system(r'allure generate {0} -o {1} --clean'.format(temp_path, html_path))
|
||||
# os.system(r'allure generate {0} -o {1} --clean'.format(temp_path, html_path))
|
||||
# 打开报告服务 并指定端口
|
||||
os.system(r'allure serve {0} -p 11999'.format(temp_path))
|
||||
# os.system(r'allure serve {0} -p 11999'.format(temp_path))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
devicelist:
|
||||
case:
|
||||
- address: /v1/region/device/
|
||||
assert:
|
||||
jsonpath:
|
||||
- asserttype: ==
|
||||
path: $.code
|
||||
value: 0
|
||||
sqlassert: null
|
||||
time: 2
|
||||
data:
|
||||
param: region_id=175&page=1&page_size=20
|
||||
urlparam: null
|
||||
headers:
|
||||
Accept: application/json, text/plain, */*
|
||||
Accept-Encoding: gzip, deflate
|
||||
Accept-Language: zh-CN,zh;q=0.9,zh-TW;q=0.8,en-US;q=0.7,en;q=0.6
|
||||
Authorization: JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxOTYsInVzZXJuYW1lIjoiZmluc2lvdCIsImV4cCI6MTY0NDM2OTcyNiwiZW1haWwiOiIifQ.2G1hxQ-9tBM_28EQF_5BXenbscS5eN7S1MsWKBLkiR0
|
||||
Cache-Control: no-cache
|
||||
Cookie: lang=zh-cn; device=desktop; theme=default; csrftoken=i3BFi3N7UyV8ADxIKw1Ts9QWnHZLyxJr58qL80pQkVlEcbFeS58cHBSuFQv8WOCX;
|
||||
SECKEY_ABVK=y4NDpBZ3j5eVz6ffWU6HWlQc+0eN9AViLny+PBLjSQs%3D; BMAP_SECKEY=cde6ebb241c3d75c675c8688828640edba33c570fc006f6ccdee864f2e95d88033fc19e794fee19c2417a6953ba260f3e91efa7e82cbc9c45b5854aec79ce924f4bcaff869b5f13c1cfe29e4aa7e8b94be82b40270a830df686cb8371107abc616aad5a33af9947528bfb4a620cb97839a7160a3191002a0bd26433da8737ed27e6af5a970caf56b88a1e60f1e6cba90b5be6d306a806f93972e5d4b46aec1c35d1c0d101de5c1fcfcf63cf49d4a7b78aa3958167b62ed00a68dd90e037e2c2c304f1ebc68421d7d05fa39e3eeba26dc82dd16876212d822ffc8f228a51dd1eaf542ecba02e1ae28ba956b0a69250790
|
||||
Host: dashboard.finsiot.com
|
||||
Pragma: no-cache
|
||||
Proxy-Connection: keep-alive
|
||||
Referer: http://dashboard.finsiot.com/web/monitor/device
|
||||
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
|
||||
like Gecko) Chrome/94.0.4606.71 Safari/537.36
|
||||
host: host
|
||||
info: É豸Áбí-²éѯ
|
||||
method: GET
|
||||
relevance: null
|
||||
name: É豸Áбí
|
||||
order: 1
|
||||
token: Authorization
|
|
@ -8,6 +8,7 @@ firmwareList:
|
|||
host: 'host'
|
||||
address: '/v1/device/firmware/'
|
||||
method: 'get'
|
||||
cache:
|
||||
relevance:
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
|
@ -31,32 +32,20 @@ firmwareList:
|
|||
}
|
||||
sqlassert:
|
||||
time: 2
|
||||
firmwareAdd:
|
||||
name: '固件新增'
|
||||
token: "Authorization"
|
||||
order: 1
|
||||
file:
|
||||
case:
|
||||
- info: "固件新增"
|
||||
- info: "固件列表获取2"
|
||||
host: 'host'
|
||||
address: '/v1/device/firmware/'
|
||||
method: 'post'
|
||||
method: 'get'
|
||||
cache:
|
||||
relevance:
|
||||
- cachefrom: 'response' # response : 从结果中获取 body : 从参数中获取
|
||||
path: '$.data.id' # body如果是 "id=2&path=haha" 会转换成字典 然后根据path使用jsonpath取值
|
||||
name: 'firmwareId'
|
||||
- relCaseName: login
|
||||
relCaseNum: 1
|
||||
value: $.data.token
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
data:
|
||||
param:
|
||||
{
|
||||
"desc": "测试",
|
||||
"name": "测试固件$RandomString($RandomPosInt(2,8)$)$",
|
||||
"size": "20",
|
||||
"url": "V1.0.$RandomPosInt(6,8)$.rbl",
|
||||
"category": "F001"
|
||||
}
|
||||
urlparam:
|
||||
assert:
|
||||
jsonpath:
|
||||
|
@ -74,6 +63,49 @@ firmwareAdd:
|
|||
}
|
||||
sqlassert:
|
||||
time: 2
|
||||
#firmwareAdd:
|
||||
# name: '固件新增'
|
||||
# token: "Authorization"
|
||||
# order: 1
|
||||
# file:
|
||||
# case:
|
||||
# - info: "固件新增"
|
||||
# host: 'host'
|
||||
# address: '/v1/device/firmware/'
|
||||
# method: 'post'
|
||||
# relevance:
|
||||
# - cachefrom: 'response' # response : 从结果中获取 body : 从参数中获取
|
||||
# path: '$.data.id' # body如果是 "id=2&path=haha" 会转换成字典 然后根据path使用jsonpath取值
|
||||
# name: 'firmwareId'
|
||||
# headers: {
|
||||
# "Content-Type": "application/json"
|
||||
# }
|
||||
# data:
|
||||
# param:
|
||||
# {
|
||||
# "desc": "测试",
|
||||
# "name": "测试固件$RandomString($RandomPosInt(2,8)$)$",
|
||||
# "size": "20",
|
||||
# "url": "V1.0.$RandomPosInt(6,8)$.rbl",
|
||||
# "category": "F001"
|
||||
# }
|
||||
# urlparam:
|
||||
# assert:
|
||||
# jsonpath:
|
||||
# - {
|
||||
# "path": "$.msg",
|
||||
# "value": "Success.",
|
||||
# "asserttype": "==",
|
||||
# "relevanceCheck":
|
||||
# }
|
||||
# - {
|
||||
# "path": "$.code",
|
||||
# "value": 0,
|
||||
# "asserttype": "==",
|
||||
# "relevanceCheck":
|
||||
# }
|
||||
# sqlassert:
|
||||
# time: 2
|
||||
firmwareDetail:
|
||||
name: '固件详情'
|
||||
token: "Authorization"
|
||||
|
@ -84,7 +116,11 @@ firmwareDetail:
|
|||
host: 'host'
|
||||
address: '/v1/device/firmware/$url(firmwareId)$/'
|
||||
method: 'get'
|
||||
cache:
|
||||
relevance:
|
||||
- relCaseName: firmwareList
|
||||
relCaseNum: 1
|
||||
value: $.data.token
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Authorization": NULL
|
||||
|
@ -109,37 +145,37 @@ firmwareDetail:
|
|||
}
|
||||
sqlassert:
|
||||
time: 2
|
||||
firmwareDel:
|
||||
name: '固件删除'
|
||||
token: "Authorization"
|
||||
order: 3
|
||||
file:
|
||||
case:
|
||||
- info: "固件删除"
|
||||
host: 'host'
|
||||
address: '/v1/device/firmware/$url(firmwareId)$/'
|
||||
method: 'delete'
|
||||
relevance:
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
}
|
||||
data:
|
||||
param:
|
||||
urlparam:
|
||||
firmwareId: "$caches(firmwareId)$"
|
||||
assert:
|
||||
jsonpath:
|
||||
- {
|
||||
"path": "$.msg",
|
||||
"value": "Success.",
|
||||
"asserttype": "==",
|
||||
"relevanceCheck":
|
||||
}
|
||||
- {
|
||||
"path": "$.code",
|
||||
"value": 0,
|
||||
"asserttype": "==",
|
||||
"relevanceCheck":
|
||||
}
|
||||
sqlassert:
|
||||
time: 2
|
||||
#firmwareDel:
|
||||
# name: '固件删除'
|
||||
# token: "Authorization"
|
||||
# order: 3
|
||||
# file:
|
||||
# case:
|
||||
# - info: "固件删除"
|
||||
# host: 'host'
|
||||
# address: '/v1/device/firmware/$url(firmwareId)$/'
|
||||
# method: 'delete'
|
||||
# relevance:
|
||||
# headers: {
|
||||
# "Content-Type": "application/x-www-form-urlencoded"
|
||||
# }
|
||||
# data:
|
||||
# param:
|
||||
# urlparam:
|
||||
# firmwareId: "$caches(firmwareId)$"
|
||||
# assert:
|
||||
# jsonpath:
|
||||
# - {
|
||||
# "path": "$.msg",
|
||||
# "value": "Success.",
|
||||
# "asserttype": "==",
|
||||
# "relevanceCheck":
|
||||
# }
|
||||
# - {
|
||||
# "path": "$.code",
|
||||
# "value": 0,
|
||||
# "asserttype": "==",
|
||||
# "relevanceCheck":
|
||||
# }
|
||||
# sqlassert:
|
||||
# time: 2
|
|
@ -7,6 +7,7 @@ login:
|
|||
host: 'host'
|
||||
address: '/v1/oauth/login/'
|
||||
method: 'post'
|
||||
cache:
|
||||
relevance:
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
@ -55,6 +56,7 @@ login:
|
|||
host: 'host'
|
||||
address: '/v1/oauth/login/'
|
||||
method: 'post'
|
||||
cache:
|
||||
relevance:
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
# coding:utf-8
|
||||
|
||||
import logging
|
||||
|
||||
import allure
|
||||
import pytest
|
||||
|
||||
from common.checkResult import asserting
|
||||
from scripts.log import Log
|
||||
from scripts.readYamlFile import ini_yaml
|
||||
from common.basePage import apisend
|
||||
|
||||
|
||||
Log()
|
||||
__all__ = [
|
||||
'pytest',
|
||||
'asserting',
|
||||
'Log',
|
||||
'ini_yaml',
|
||||
'logging',
|
||||
'allure',
|
||||
'apisend',
|
||||
]
|
|
@ -1,2 +0,0 @@
|
|||
# coding:utf-8
|
||||
from test_suite.testcase.fengling import *
|
|
@ -1 +0,0 @@
|
|||
# coding:utf-8
|
|
@ -1,29 +0,0 @@
|
|||
# coding:utf-8
|
||||
from test_suite.page.saasApp.saasApp_pages import *
|
||||
|
||||
paramData = ini_yaml("loginData.yml")["login"][0]
|
||||
thirdParamData = ini_yaml("loginData.yml")["login"][0]
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def setup_login():
|
||||
logging.info("前置请求登录")
|
||||
data = urlData["login"]
|
||||
logging.info("{}".format(paramData["info"]))
|
||||
res, restime = apisend(address=data["address"], method=data["method"], headers=paramData["headers"],
|
||||
data=paramData["data"],rel=data["relevance"])
|
||||
|
||||
logging.info("前置请求结束")
|
||||
return res
|
||||
|
||||
|
||||
thirdURL = ini_yaml("thirdUrl.yml")
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def third_login():
|
||||
data = thirdURL["weblogin"]
|
||||
logging.info("{}".format(paramData["info"]))
|
||||
res, restime = apisend(address=data["address"], method=data["method"], headers=paramData["headers"],
|
||||
data=paramData["data"],rel=data["relevance"])
|
||||
return res
|
|
@ -1,53 +0,0 @@
|
|||
# coding:utf-8
|
||||
"""
|
||||
@author: 井松
|
||||
@contact: 529548204@qq.com
|
||||
@file: test_alarm.py
|
||||
@time: 2021/9/14 16:40
|
||||
"""
|
||||
from test_suite.page.saasApp_pages import *
|
||||
paramData = ini_yaml("alarmData.yml")
|
||||
|
||||
|
||||
class Test_alarm(object):
|
||||
# def setup(self):
|
||||
# self.re = saasPages()
|
||||
# ids=[i["info"] for i in paramData["login"]]
|
||||
@allure.story("Test_alarmStatistic")
|
||||
@pytest.mark.parametrize('casedata', paramData["alarmStatistic"], ids=[i["info"] for i in paramData["alarmStatistic"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_alarmStatistic(self, setup_login, casedata):
|
||||
casedata["headers"]["Authorization"] = "JWT " + setup_login["data"]["token"]
|
||||
res, restime = alarmStatistic(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res, re_time=restime)
|
||||
|
||||
@allure.story("Test_alarmTrend")
|
||||
@pytest.mark.parametrize('casedata', paramData["alarmTrend"], ids=[i["info"] for i in paramData["alarmTrend"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_alarmTrend(self, setup_login, casedata):
|
||||
casedata["headers"]["Authorization"] = "JWT " + setup_login["data"]["token"]
|
||||
res, restime = alarmTrend(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res, re_time=restime)
|
||||
|
||||
@allure.story("Test_alarmRank")
|
||||
@pytest.mark.parametrize('casedata', paramData["alarmRank"], ids=[i["info"] for i in paramData["alarmRank"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_alarmRank(self ,setup_login, casedata):
|
||||
casedata["headers"]["Authorization"] = "JWT " + setup_login["data"]["token"]
|
||||
res, restime = alarmRank(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res, re_time=restime)
|
||||
|
||||
@allure.story("Test_alarmDistribute")
|
||||
@pytest.mark.parametrize('casedata', paramData["alarmDistribute"], ids=[i["info"] for i in paramData["alarmDistribute"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_alarmDistribute(self, setup_login, casedata):
|
||||
casedata["headers"]["Authorization"] = "JWT " + setup_login["data"]["token"]
|
||||
res, restime = alarmDistribute(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res, re_time=restime)
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(111)
|
|
@ -1,21 +0,0 @@
|
|||
# coding:utf-8
|
||||
"""
|
||||
@author: 井松
|
||||
@contact: 529548204@qq.com
|
||||
@file: test_function.py
|
||||
@time: 2021/10/8 15:02
|
||||
"""
|
||||
from test_suite.page.saasApp.saasApp_pages import *
|
||||
# from test_suite.page.third_pages import *
|
||||
paramData = ini_yaml("functionData.yml")
|
||||
# thirdData = ini_yaml("thirdData.yml")
|
||||
|
||||
class Test_function(object):
|
||||
@allure.story("Test_functionList")
|
||||
@pytest.mark.parametrize('casedata', paramData["functionList"], ids=[i["info"] for i in paramData["functionList"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_functionList(self, setup_login, casedata):
|
||||
casedata["headers"]["Authorization"] = "JWT " + setup_login["data"]["token"]
|
||||
res, restime = functionList(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res, re_time=restime)
|
|
@ -1,64 +0,0 @@
|
|||
# coding:utf-8
|
||||
from test_suite.page.saasApp.saasApp_pages import *
|
||||
|
||||
paramData = ini_yaml("homePageData.yml")
|
||||
|
||||
|
||||
class Test_homePage(object):
|
||||
# def setup(self):
|
||||
# self.re = saasPages()
|
||||
# ids=[i["info"] for i in paramData["login"]]
|
||||
@allure.story("Test_todayTasks")
|
||||
@pytest.mark.parametrize('casedata', paramData["todayTasks"], ids=[i["info"] for i in paramData["todayTasks"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_todayTasks(self, setup_login, casedata):
|
||||
casedata["headers"]["Authorization"] = "JWT " + setup_login["data"]["token"]
|
||||
res, restime = todayTask(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res, re_time=restime)
|
||||
|
||||
@allure.story("Test_companyName")
|
||||
@pytest.mark.parametrize('casedata', paramData["companyName"], ids=[i["info"] for i in paramData["companyName"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_companyName(self,setup_login, casedata):
|
||||
casedata["headers"]["Authorization"] = "JWT " + setup_login["data"]["token"]
|
||||
res, restime = companyName(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res, re_time=restime)
|
||||
|
||||
@allure.story("Test_companyPower")
|
||||
@pytest.mark.parametrize('casedata', paramData["companyPower"], ids=[i["info"] for i in paramData["companyPower"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_companyPower(self,setup_login, casedata):
|
||||
casedata["headers"]["Authorization"] = "JWT " + setup_login["data"]["token"]
|
||||
res, restime = companyPower(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res, re_time=restime)
|
||||
|
||||
@allure.story("Test_deviceState")
|
||||
@pytest.mark.parametrize('casedata', paramData["deviceState"], ids=[i["info"] for i in paramData["deviceState"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_deviceState(self,setup_login, casedata):
|
||||
casedata["headers"]["Authorization"] = "JWT " + setup_login["data"]["token"]
|
||||
res, restime = deviceState(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res, re_time=restime)
|
||||
|
||||
@allure.story("Test_companyAlarm")
|
||||
@pytest.mark.parametrize('casedata', paramData["companyAlarm"], ids=[i["info"] for i in paramData["companyAlarm"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_companyAlarm(self,setup_login, casedata):
|
||||
casedata["headers"]["Authorization"] = "JWT " + setup_login["data"]["token"]
|
||||
res, restime = companyAlarm(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res, re_time=restime)
|
||||
|
||||
@allure.story("Test_todayTrend")
|
||||
@pytest.mark.parametrize('casedata', paramData["todayTrend"], ids=[i["info"] for i in paramData["todayTrend"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_todayTrend(self,setup_login, casedata):
|
||||
allure.attach("未验证数据准确性")
|
||||
casedata["headers"]["Authorization"] = "JWT " + setup_login["data"]["token"]
|
||||
res, restime = todayTrend(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res, re_time=restime)
|
|
@ -1,40 +0,0 @@
|
|||
# coding:utf-8
|
||||
import pytest
|
||||
|
||||
from test_suite.page.saasApp.saasApp_pages import *
|
||||
|
||||
paramData = ini_yaml("loginData.yml")
|
||||
|
||||
|
||||
class Test_login(object):
|
||||
# def setup(self):
|
||||
# self.re = saasPages()
|
||||
# ids=[i["info"] for i in paramData["login"]]
|
||||
@allure.story("Test_login")
|
||||
@pytest.mark.parametrize('casedata', paramData["login"], ids=[i["info"] for i in paramData["login"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_login(self, casedata):
|
||||
res, restime = login(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res,re_time=restime)
|
||||
|
||||
@allure.story("Test_mobileCode")
|
||||
@pytest.mark.parametrize('casedata', paramData["mobileCode"], ids=[i["info"] for i in paramData["mobileCode"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_mobileCode(self, casedata):
|
||||
res, restime = mobileCode(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res,re_time=restime)
|
||||
# cache.set("session_id", res["session_id"])
|
||||
|
||||
|
||||
@allure.story("Test_forgetPassword")
|
||||
@pytest.mark.parametrize('casedata', paramData["forgetPassword"], ids=[i["info"] for i in paramData["forgetPassword"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
@pytest.mark.skip("验证码异常")
|
||||
def test_forgetPassword(self, casedata,cache):
|
||||
res, restime = mobileCode(paramData["mobileCode"][1])
|
||||
casedata['data']["param"]['session_key'] = cache.get('k',None)
|
||||
res, restime = forgetPassword(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res,re_time=restime)
|
|
@ -1,44 +0,0 @@
|
|||
# coding:utf-8
|
||||
"""
|
||||
@author: 井松
|
||||
@contact: 529548204@qq.com
|
||||
@file: test_power.py
|
||||
@time: 2021/9/17 16:56
|
||||
"""
|
||||
from test_suite.page.saasApp.saasApp_pages import *
|
||||
from test_suite.page.saasApp.third_pages import *
|
||||
|
||||
paramData = ini_yaml("powerData.yml")
|
||||
thirdData = ini_yaml("thirdData.yml")
|
||||
|
||||
|
||||
class Test_power(object):
|
||||
# def setup(self):
|
||||
# self.re = saasPages()
|
||||
# ids=[i["info"] for i in paramData["login"]]
|
||||
@allure.story("Test_powerToday")
|
||||
@pytest.mark.parametrize('casedata', paramData["powerToday"], ids=[i["info"] for i in paramData["powerToday"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_powerToday(self, setup_login, casedata):
|
||||
casedata["headers"]["Authorization"] = "JWT " + setup_login["data"]["token"]
|
||||
res, restime = powerToday(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res, re_time=restime)
|
||||
|
||||
@allure.story("Test_powerFees")
|
||||
@pytest.mark.parametrize('casedata', paramData["powerFees"], ids=[i["info"] for i in paramData["powerFees"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_powerFees(self, third_login, setup_login, casedata):
|
||||
|
||||
casedata["headers"]["Authorization"] = "JWT " + setup_login["data"]["token"]
|
||||
|
||||
thirdData["webFees"][0]["headers"]["Authorization"] = "JWT " + third_login["data"]["token"]
|
||||
thirdData["webPower"][0]["headers"]["Authorization"] = "JWT " + third_login["data"]["token"]
|
||||
webFeesRes = webFees(thirdData["webFees"][0])[0]
|
||||
webPowerRes = webPower(thirdData["webPower"][0])[0]
|
||||
third_datas = {**webFeesRes,**webPowerRes}
|
||||
# 电费断言
|
||||
res, restime = powerFees(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res, re_time=restime,third_datas=third_datas)
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
# coding:utf-8
|
||||
"""
|
||||
@author: 井松
|
||||
@contact: 529548204@qq.com
|
||||
@file: test_region.py
|
||||
@time: 2021/10/8 16:11
|
||||
"""
|
||||
from test_suite.page.saasApp.saasApp_pages import *
|
||||
# from test_suite.page.third_pages import *
|
||||
paramData = ini_yaml("regionData.yml")
|
||||
# thirdData = ini_yaml("thirdData.yml")
|
||||
|
||||
class Test_function(object):
|
||||
@allure.story("Test_functionList")
|
||||
@pytest.mark.parametrize('casedata', paramData["functionList"], ids=[i["info"] for i in paramData["functionList"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_functionList(self, setup_login, casedata):
|
||||
casedata["headers"]["Authorization"] = "JWT " + setup_login["data"]["token"]
|
||||
res, restime = functionList(casedata)
|
||||
asserting(hope_res=casedata["assert"], real_res=res, re_time=restime)
|
|
@ -6,10 +6,10 @@ import allure
|
|||
import pytest
|
||||
|
||||
from common.checkResult import asserting
|
||||
from scripts.log import Log
|
||||
from scripts.readYamlFile import ini_yaml
|
||||
from util.tools.log import Log
|
||||
from util.tools.readYamlFile import ini_yaml
|
||||
from common.basePage import apisend
|
||||
|
||||
alldata = ini_yaml()
|
||||
|
||||
Log()
|
||||
__all__ = [
|
||||
|
@ -20,4 +20,5 @@ __all__ = [
|
|||
'logging',
|
||||
'allure',
|
||||
'apisend',
|
||||
'alldata',
|
||||
]
|
|
@ -5,18 +5,20 @@
|
|||
@file: conftest.py
|
||||
@time: 2021/12/3 14:25
|
||||
"""
|
||||
import pytest
|
||||
|
||||
from test_suite.testcase.saasWeb import *
|
||||
|
||||
paramData = ini_yaml("login.yml")["login"]["case"]
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def setup_Login():
|
||||
logging.info("前置请求登录")
|
||||
paramData = alldata["login"]["case"]
|
||||
logging.info("{}".format(paramData[0]["info"]))
|
||||
res, restime = apisend(host=paramData[0]["host"], address=paramData[0]["address"], method=paramData[0]["method"],
|
||||
headers=paramData[0]["headers"],
|
||||
data=paramData[0]["data"], rel=paramData[0]["relevance"])
|
||||
data=paramData[0]["data"], rel=paramData[0]["cache"])
|
||||
|
||||
logging.info("前置请求结束")
|
||||
return "JWT " + res["data"]["token"]
|
||||
|
@ -25,10 +27,11 @@ def setup_Login():
|
|||
@pytest.fixture(scope="session")
|
||||
def setup_Login_zhongtai():
|
||||
logging.info("中台前置请求登录")
|
||||
paramData = alldata["login"]["case"]
|
||||
logging.info("{}".format(paramData[1]["info"]))
|
||||
res, restime = apisend(host=paramData[1]["host"], address=paramData[1]["address"], method=paramData[1]["method"],
|
||||
headers=paramData[1]["headers"],
|
||||
data=paramData[1]["data"], rel=paramData[1]["relevance"])
|
||||
data=paramData[1]["data"], rel=paramData[1]["cache"])
|
||||
|
||||
logging.info("前置请求结束")
|
||||
return "JWT " + res["data"]["token"]
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
from test_suite.testcase.saasWeb import *
|
||||
|
||||
paramData = ini_yaml("/firmware/device.yml")
|
||||
|
||||
class Test_device(object):
|
||||
@allure.story("Test_device")
|
||||
@pytest.mark.parametrize('casedata', paramData["devicelist"]["case"],
|
||||
ids=[i["info"] for i in paramData["devicelist"]["case"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_devicelist(self, casedata, setup_Login):
|
||||
casedata["headers"]["Authorization"] = setup_Login
|
||||
res, restime = apisend(host=casedata["host"], address=casedata["address"], method=casedata["method"],
|
||||
headers=casedata["headers"],
|
||||
data=casedata["data"], rel=casedata["relevance"])
|
||||
asserting(hope_res=casedata["assert"], real_res=res, re_time=restime)
|
|
@ -1,15 +1,15 @@
|
|||
from test_suite.testcase.saasWeb import *
|
||||
|
||||
paramData = ini_yaml("/login.yml")
|
||||
|
||||
|
||||
class Test_login(object):
|
||||
@allure.story("Test_login")
|
||||
@pytest.mark.parametrize('casedata', paramData["login"]["case"],
|
||||
ids=[i["info"] for i in paramData["login"]["case"]])
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.run(order=1)
|
||||
def test_login(self, casedata):
|
||||
res, restime = apisend(host=casedata["host"], address=casedata["address"], method=casedata["method"],
|
||||
headers=casedata["headers"],
|
||||
data=casedata["data"], rel=casedata["relevance"])
|
||||
asserting(hope_res=casedata["assert"], real_res=res, re_time=restime)
|
||||
|
||||
def test_login(self,setup_Login):
|
||||
data = alldata["firmwareList"]
|
||||
# res, restime = apisend(host=alldata[1]["host"], address=paramData[1]["address"],
|
||||
# method=paramData[1]["method"],
|
||||
# headers=paramData[1]["headers"],
|
||||
# data=paramData[1]["data"], rel=paramData[1]["cache"])
|
||||
|
||||
print(data)
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
from test_suite.testcase.saasWeb import *
|
||||
|
||||
|
||||
class Test_firmware(object):
|
||||
|
||||
@pytest.mark.parametrize('casedata', alldata["firmwareList"]["case"],
|
||||
ids=[i["info"] for i in alldata["firmwareList"]["case"]])
|
||||
def test_firmwareList(self, setup_Login, casedata):
|
||||
casedata["headers"]["Authorization"] = setup_Login
|
||||
res, restime = apisend(host=casedata["host"], address=casedata["address"],
|
||||
method=casedata["method"], headers=casedata["headers"], data=casedata["data"],
|
||||
rel=casedata["cache"])
|
||||
print(res)
|
|
@ -0,0 +1,8 @@
|
|||
# coding:utf-8
|
||||
import os
|
||||
|
||||
root_path = str(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))).replace("\\","/")
|
||||
|
||||
__all__ = [
|
||||
"root_path",
|
||||
]
|
|
@ -54,13 +54,14 @@ class Counter:
|
|||
detail["token"] = "Authorization"
|
||||
detail["order"] = self.num
|
||||
detail["case"] = [case]
|
||||
detail["file"] = False
|
||||
|
||||
case["info"] = name
|
||||
case["host"] = "host" # 可参数化
|
||||
case["address"] = u[0]
|
||||
case["relevance"] = None
|
||||
case["headers"] = {}
|
||||
case["headers"] = dict(headers)
|
||||
case["file"] = False
|
||||
|
||||
data["file"] = None
|
||||
data["param"] = None
|
|
@ -2,23 +2,11 @@
|
|||
import os
|
||||
|
||||
from config.confManage import dir_manage
|
||||
from scripts.readYamlFile import ini_yaml
|
||||
from scripts import root_path
|
||||
from util.tools.readYamlFile import ini_yaml
|
||||
from util.tools import root_path
|
||||
from util.tools.getFileNames import getFilePathList
|
||||
import time
|
||||
|
||||
def getFilePathList(rootpath, filetype):
|
||||
filepath = []
|
||||
# 获取所有文件下的子文件名称
|
||||
for root, dirs, files in os.walk(rootpath):
|
||||
# 过滤所有空文件
|
||||
if files:
|
||||
for file in files:
|
||||
path = os.path.join(root, file)
|
||||
# 判断只返回 yaml 的文件
|
||||
if filetype in path:
|
||||
filepath.append(str(path).replace("\\", "/"))
|
||||
return filepath
|
||||
|
||||
|
||||
def write_case():
|
||||
testname = dir_manage('${test_name}$')
|
||||
|
@ -29,7 +17,7 @@ def write_case():
|
|||
|
||||
file = str(filepath.split(datapath)[-1]) # 处理出文件名及路径
|
||||
filename = str(filepath.split("/")[-1].split(".")[0]) # 测试用例名称
|
||||
filedata = ini_yaml(file) # 测试数据
|
||||
filedata = ini_yaml() # 测试数据
|
||||
midp = file.split(filename + ".yml")[0] # 分层路径获取
|
||||
case = casepath + midp + "test_" + filename + ".py" # 用例路径
|
||||
if not os.path.exists(casepath + midp):
|
|
@ -4,7 +4,7 @@ import warnings
|
|||
|
||||
warnings.simplefilter('ignore', DeprecationWarning)
|
||||
import pymysql
|
||||
from scripts.log import Log
|
||||
from util.tools.log import Log
|
||||
import logging
|
||||
from config.confManage import db_manage
|
||||
import time
|
|
@ -2,9 +2,9 @@
|
|||
import logging
|
||||
import time
|
||||
import os
|
||||
from scripts.mkDir import mk_dir
|
||||
from util.tools.mkDir import mk_dir
|
||||
from config.confManage import dir_manage
|
||||
from scripts import root_path
|
||||
from util.tools import root_path
|
||||
|
||||
|
||||
class Log(object):
|
|
@ -7,7 +7,7 @@ import time
|
|||
import string
|
||||
import jsonpath
|
||||
from faker import Faker
|
||||
from scripts.relevance import Cache
|
||||
from util.tools.relevance import Cache
|
||||
|
||||
|
||||
def choice_data(data):
|
|
@ -0,0 +1,38 @@
|
|||
# coding:utf-8
|
||||
import os
|
||||
|
||||
import yaml
|
||||
|
||||
from config.confManage import dir_manage
|
||||
from util.scripts import root_path
|
||||
from util.tools.getFileNames import getFilePathList
|
||||
|
||||
datapath = root_path + dir_manage("${test_suite}$") + dir_manage("${data_dir}$") + "/" + dir_manage("${test_name}$")
|
||||
|
||||
|
||||
def ini_yaml():
|
||||
alldata = {}
|
||||
datalist = getFilePathList(datapath,".yml")
|
||||
for file in datalist:
|
||||
try:
|
||||
with open(file, 'r', encoding="utf-8") as f:
|
||||
file_data = f.read()
|
||||
alldata= {**alldata,**yaml.safe_load(file_data)}
|
||||
except UnicodeDecodeError:
|
||||
with open(file, 'r') as f:
|
||||
file_data = f.read()
|
||||
alldata= {**alldata,**yaml.safe_load(file_data)}
|
||||
print("*"*200)
|
||||
return alldata
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# print(datapath)
|
||||
# get_yaml_data(r"F:\api2.0\config\runConfig.yml")
|
||||
d = ini_yaml()
|
||||
print(d)
|
||||
# # case_level = runConfig_dict[0]["address"].format(**{"home_id": "123"})
|
||||
# print(runConfig_dict)
|
||||
|
||||
# print(case_level)
|
||||
# print(type(case_level))
|
|
@ -10,8 +10,8 @@ import os
|
|||
import shutil
|
||||
|
||||
import jsonpath
|
||||
from scripts.mkDir import mk_dir
|
||||
from scripts import root_path
|
||||
from util.tools.mkDir import mk_dir
|
||||
from util.tools import root_path
|
||||
|
||||
from config.confManage import dir_manage
|
||||
|
||||
|
@ -74,29 +74,23 @@ class Cache(object):
|
|||
elif os.path.isdir(file_path):
|
||||
shutil.rmtree(file_path)
|
||||
|
||||
|
||||
class Relevance(object):
|
||||
|
||||
def __init__(self):
|
||||
self.caches = Cache()
|
||||
|
||||
def respons_cache(self, data, respons):
|
||||
values = jsonpath.jsonpath(respons, data['path'])
|
||||
if not values:
|
||||
raise ValueError("path错误")
|
||||
self.caches.set(key=data["name"], value=values[0])
|
||||
self.set(key=data["name"], value=values[0])
|
||||
|
||||
def body_cache(self, data, param):
|
||||
if isinstance(param, dict):
|
||||
values = jsonpath.jsonpath(param, data['path'])
|
||||
if not values:
|
||||
raise ValueError("path错误")
|
||||
self.caches.set(key=data["name"], value=values[0])
|
||||
self.set(key=data["name"], value=values[0])
|
||||
else:
|
||||
values = jsonpath.jsonpath(valueHandle(param), data['path'])
|
||||
if not values:
|
||||
raise ValueError("path错误")
|
||||
self.caches.set(key=data["name"], value=values[0])
|
||||
self.set(key=data["name"], value=values[0])
|
||||
|
||||
def relevance(self, data, bodys=None, res=None):
|
||||
if data is not None:
|
||||
|
@ -126,10 +120,10 @@ if __name__ == '__main__':
|
|||
'name': '测试固件dE8', 'size': 20.0, 'category': 'F001', 'desc': '测试', 'url': 'V1.0.6.rbl'}}
|
||||
# bo = "code=200&msg=success"
|
||||
bo ={"a":1}
|
||||
# from scripts.readYamlFile import ini_yaml
|
||||
# util.tools.readYamlFile import ini_yaml
|
||||
#
|
||||
# s1 = ini_yaml("firmware.yml", r"D:\apitest\test_suite\datas\saasWeb\firmware")
|
||||
rels = Relevance()
|
||||
rels = Cache()
|
||||
|
||||
rels.relevance(s["case"][0]["relevance"], bodys=bo, res=ress)
|
||||
# rels.caches.clear_cache("firmwareId")
|
Loading…
Reference in New Issue