Api_God???????????
???????????????? ???????[ 2017/2/22 10:37:07 ] ??????????????? ????????
????God?????????
????1.?????????????
????2.???????????
????3.?????????????????????
?????????????
???????????HtmlTestRunner.py?????????????????????????????????????????
??????????????????
???????
????· ???????????????????????????unittest?????????????????
????· ??????????????κι??????????????????
????· ??????????????????????????????????????????????50%????????
???????
????· ??????????????????п???????????????????????????????????
????· ????????????????????????????????д????????????????????????
????· ????壬????????????????????????
?????????????????????????????????????????д??????????????????????????????????????????
????· Mysql????????
CREATE TABLE test_result (
`id` int(11) NOT NULL AUTO_INCREMENT??
`if_name` varchar(10) Not Null comment '???????'??
`case_name` varchar(20) comment '????????'??
`status` varchar(5)?? `result` varchar(20)??
`response` varchar(1000)?? `url_target` varchar(20) comment '???????'??
`comment` varchar(30)??
`type` varchar(10) comment '??н??????'??
`uptm` timestamp not null?? PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
????! ?????Щ??Σ??????????????????????????
????
???
?????????о???????
from Src.Function.ApiMethod import Api_urllib
from Src.Function.LogMainClass import *
from Src.Function.MySql import MySQL
class CheckPay(Api_urllib):
def setUp(self):
self.comment = '??????????'
self.casename = "test_CheckPay"
self.interfacename = 'd13'
self.result = 'Fail'
self.response = "Null"
self.status = '0'
def test_CheckPay(self):
casename = self.casename
response = ''
status_code = ''
transnumber = Api_urllib.read_from_file('d08ford12d13').split('??')[0]
try:
# ???????????
cookie = Api_urllib.read_cookie_file('100')
parameter = {'r': '123'?? 'transnumber': transnumber}
response?? status_code = Api_urllib.getInterface_requests_status(parameter?? headers=cookie)
# ????嵱??????????У?鵽??Щ???????Pass
self.result = "Pass"
except Exception as msg:
print (msg)
raise
finally:
# ?????????????? ??? ?????У?set_test_result ?????????
MySQL.set_test_result(response?? status_code?? self.interfacename?? self.casename?? self.comment?? self.result)
def tearDown(self):
do something
?????????
????1.??setup????г??????????????????????????setup;
????2.test_checkpay????????壬???????????????? Api_urllib.getInterface_requests_status()???????response??status_code;
????3.????????????????????????????????????
????4.????????????MySQL.set_test_result()???????б?????????????????????????????response??????2?δ??????????????????????
????5.????set_test_result()?????????json?????respose???ж??δ??????????Щ????????????д???
def set_test_result(cls?? response?? status_code?? interfacename?? casename?? comment?? result):
status = ''
try:
status = response['succ']
cls.response_new = 'succ:%s' % response['succ']
if response['succ'] != '1':
cls.response_new = response['msg']
except:
status = status_code
#` todo_string() `?????????????????
cls.response_new = MySQL.todo_string(response)
finally:
MySQL.insert(interfacename?? casename?? comment?? status?? result?? cls.response_new)
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11