def __call__(self):
self.before()
headers = [NVPair("Content-Type","application/json")]
submitdata = '{"user_id":"1","price":"20"}'
result = request1.POST("10.138.30.226:5000/pay",submitdata,headers)
if result.getStatusCode() == 200 :
return
elif result.getStatusCode() in (301, 302) :
grinder.logger.warn("Warning. The response may not be correct. The response code was %d." % result.getStatusCode())
return
else :
raise
#打印输出URL请求返回内容
#grinder.logger.info(result.getText())
#返回结果检查,有返回特定字符,则判断请求成功
if result.getText().find("支付成功") != -1 :
grinder.statistics.forLastTest.success = 1
else :
grinder.statistics.forLastTest.success = 0
#请求失败,则输出失败时服务器返回的值
grinder.logger.info(result.getText())