2017-06-04 20:52:17 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
# @Time : 2017/6/4 20:15
|
|
|
|
|
# @Author : lileilei
|
2017-11-01 10:28:31 +08:00
|
|
|
# @File : case.py
|
2017-06-04 20:52:17 +08:00
|
|
|
from Interface.testFengzhuang import TestApi
|
2017-06-09 21:17:12 +08:00
|
|
|
from Public.get_excel import datacel
|
2017-10-16 21:00:09 +08:00
|
|
|
from Public.log import LOG,logger
|
2017-06-06 11:05:50 +08:00
|
|
|
listid,listkey,listconeent,listurl,listfangshi,listqiwang,listname=datacel()
|
2017-08-03 13:03:33 +08:00
|
|
|
from Public.panduan import assert_in
|
2017-10-16 21:00:09 +08:00
|
|
|
@logger('测试')
|
2017-08-01 21:39:11 +08:00
|
|
|
def testinterface():
|
|
|
|
|
list_pass = 0
|
|
|
|
|
list_fail = 0
|
|
|
|
|
list_json = []
|
|
|
|
|
listrelust=[]
|
2018-03-13 13:17:23 +08:00
|
|
|
list_weizhi=0
|
|
|
|
|
list_exption=0
|
2017-08-01 21:39:11 +08:00
|
|
|
for i in range(len(listurl)):
|
|
|
|
|
api=TestApi(url=listurl[i],key=listkey[i],connent=listconeent[i],fangshi=listfangshi[i])
|
|
|
|
|
apijson=api.getJson()
|
2018-03-13 13:17:23 +08:00
|
|
|
if apijson['code']==0:
|
|
|
|
|
LOG.info('inputdata> 参数:%s, url:%s ,返回:%s,预期:%s'%(listconeent[i],listurl[i],apijson,listqiwang[i]))
|
|
|
|
|
assert_re=assert_in(asserqiwang=listqiwang[i],fanhuijson=apijson)
|
|
|
|
|
if assert_re['code']==0:
|
|
|
|
|
list_json.append(apijson['result'])
|
|
|
|
|
listrelust.append('pass')
|
|
|
|
|
list_pass += 1
|
|
|
|
|
elif assert_re['code']==1:
|
|
|
|
|
list_fail+=1
|
|
|
|
|
listrelust.append('fail')
|
|
|
|
|
list_json.append(apijson['result'])
|
|
|
|
|
elif assert_re['code']==2:
|
|
|
|
|
list_exption+=1
|
|
|
|
|
listrelust.append('exception')
|
|
|
|
|
list_json.append(assert_re['result'])
|
|
|
|
|
else:
|
|
|
|
|
list_weizhi+=1
|
|
|
|
|
listrelust.append('未知错误')
|
|
|
|
|
list_json.append('未知错误')
|
2017-08-01 21:39:11 +08:00
|
|
|
else:
|
2018-03-13 13:17:23 +08:00
|
|
|
list_exption += 1
|
|
|
|
|
listrelust.append('exception')
|
|
|
|
|
list_json.append(apijson['result'])
|
|
|
|
|
continue
|
|
|
|
|
return listrelust,list_fail,list_pass,list_json,list_exption,list_weizhi
|