1.新增上传Log日志纯接口及针对全流程log日志字段的目的性验证关键字及测试用例

This commit is contained in:
byb11
2021-05-12 15:16:59 +08:00
parent 7732256b20
commit 33ccfc3466
5 changed files with 222 additions and 145 deletions

View File

@@ -1,3 +1,6 @@
import re
import time
import jsonpath
# 1.说明:本方法用于对日志接口返回数据中的字段和数据进行判断
# 2.传入数据说明responsedict - 接口返回数据的json数据
@@ -35,11 +38,21 @@ def FieldValidation(responsedict, targetlist):
responsevalue=str(responsevalue)
if len(target) == 3:
targetvalue = target[2]
p = conditional(conditions, responsevalue, targetkey, sum, targetvalue)
strlist.append(p)
torf=is_valid_date(responsevalue)
if torf == True:
timeArray = time.strptime(responsevalue, "%Y-%m-%d %H:%M:%S")
timeStamp = str(int(time.mktime(timeArray)))
p = conditional(conditions, timeStamp, targetkey, sum, targetvalue)
if p != "":
strlist.append(p)
else:
p = conditional(conditions, responsevalue, targetkey, sum, targetvalue)
if p != "":
strlist.append(p)
elif len(target) == 2:
p = conditional(conditions, responsevalue, targetkey, sum)
strlist.append(p)
if p != "":
strlist.append(p)
else:
str2 = "返回数据第" + str(sum) + "组数据中不存在该字段:" + target[0]
print(str2)
@@ -177,3 +190,14 @@ def Assertresults(resultslist):
for i in resultslist:
if i != "":
assert 1 == 2
def is_valid_date(strdate):
'''判断是否是一个有效的日期字符串'''
a = re.findall(":", strdate)
b = re.findall("-", strdate)
if len(a) ==2 and len(b) == 2:
return True
else:
return False