Commit 1ba38314 authored by 张鹏程's avatar 张鹏程

修改接口返回样式

parent f5ad2bf5
...@@ -19,7 +19,7 @@ class Collection(BaseHandler): ...@@ -19,7 +19,7 @@ class Collection(BaseHandler):
self.write(JsonUtil.build_json_feature(businessType=int(_business_type), orderId=_orderId, loanId=_loanId, self.write(JsonUtil.build_json_feature(businessType=int(_business_type), orderId=_orderId, loanId=_loanId,
user_uuid = _uuid,user_id=_user_id,_term_no = _termNo, user_uuid = _uuid,user_id=_user_id,_term_no = _termNo,
features=_result, flag=True,code=200)) features=_result, flag=True,code=JsonUtil.Constants.Code_Success))
self.flush() self.flush()
self.finish() self.finish()
......
...@@ -17,7 +17,7 @@ class ComplexOrder(BaseHandler): # 多订单接口 ...@@ -17,7 +17,7 @@ class ComplexOrder(BaseHandler): # 多订单接口
_result = test_complex_order.complexOrder(_user_id) _result = test_complex_order.complexOrder(_user_id)
self.write(JsonUtil.build_json_feature(businessType=int(_business_type), orderId=_orderId, loanId=_loanId,user_uuid = _uuid,user_id=_user_id, self.write(JsonUtil.build_json_feature(businessType=int(_business_type), orderId=_orderId, loanId=_loanId,user_uuid = _uuid,user_id=_user_id,
features=_result, flag=True,code=200)) features=_result, flag=True,code=JsonUtil.Constants.Code_Success))
self.flush() self.flush()
self.finish() self.finish()
......
from utils.tools_requests import http from utils.tools_requests import http
from collections import defaultdict
import config.read_properties as cf import config.read_properties as cf
def get_http_response(host,url, params = None,file_path = None, method = 'GET',cookies = None): def get_response_http(host,url, params = None,file_path = None, method = 'GET',cookies = None):
_init = http(ip=host) _init = http(ip=host)
_request = _init.request_Met(url=url,params=params,method=method,cookies=cookies) _request = _init.request_Met(url=url,params=params,method=method,cookies=cookies)
_response = _init.getJson(_request) _response = _init.getJson(_request)
return _response return _response
def get_response_feature(host,url,params = None,code = None,headers=None,file_path = None, method = 'GET',cookies = None):
_init = http(ip=host)
_request = _init.request_Met(url=url,params=params,method=method,cookies=cookies,headers = headers)
_response = _init.getJson(_request)
return _response
# def get_response_features(host,url,params = None,code = None,headers=None,file_path = None, method = 'GET',cookies = None,semlock = None):
#
# dict_assert = defaultdict(str)
# headers = {
# 'rc_auth_key':'rc_developer',
# 'rc_auth_secret':'rc_secret'
# }
# _init = http(ip=host)
# _request = _init.request_Met(url=url,params=params,method=method,cookies=cookies,headers = headers)
#
# url ='http://172.20.7.12:23010/calc/features'
#
# if _request.status_code == 200 and _request.json()['code'] == 200:
# _response = _init.getJson(_request)
# for key in _response['data']['features']:
# dict_assert[key] = r_json['data']['features'][key]['value']
# # print('-----------------')
#
# if semlock:
# semlock.release()
#
# return dict(dict_assert)
...@@ -37,10 +37,7 @@ class Test(unittest.TestCase): ...@@ -37,10 +37,7 @@ class Test(unittest.TestCase):
with open(filename,'wb') as fp: with open(filename,'wb') as fp:
# #定义测试报告 # #定义测试报告
runner=HTMLTestRunner(stream=fp,title='测试报告',description='用例执行情况:',verbosity=2) runner=HTMLTestRunner(stream=fp,title='测试报告',description='用例执行情况:',verbosity=2)
runner.run(suite) runner.run(suite)
fp.close()#关闭报告文件 fp.close()#关闭报告文件
else: else:
print('testcase type error') print('testcase type error')
......
...@@ -51,11 +51,9 @@ def test_trans_v2_read(): ...@@ -51,11 +51,9 @@ def test_trans_v2_read():
pass pass
def read_feature(): def read_feature():
global url,params,method global url,params,method
_response = Http_Requests.get_http_response( _response = Http_Requests.get_response_http(
host= IP.FEATURE_HOST, host= IP.FEATURE_HOST,
url = IP.url_trans_v2_read, url = IP.url_trans_v2_read,
params=params, params=params,
...@@ -65,7 +63,7 @@ def read_feature(): ...@@ -65,7 +63,7 @@ def read_feature():
return _response return _response
def read_feature_my(): def read_feature_my():
global url,params,method global url,params,method
_response = Http_Requests.get_http_response( _response = Http_Requests.get_response_http(
host= IP.FEATURE_HOST_MY, host= IP.FEATURE_HOST_MY,
url = IP.url_trans_v2_read, url = IP.url_trans_v2_read,
params=params, params=params,
......
...@@ -9,7 +9,7 @@ import json ...@@ -9,7 +9,7 @@ import json
## 常数变量定义 ## 常数变量定义
## json 返回中的 错误码定义 ## json 返回中的 错误码定义
class Constants: class Constants:
Code_Success = '0000' Code_Success = '200'
Msg_Success = 'SUCCESS' Msg_Success = 'SUCCESS'
Code_Fail = 1 Code_Fail = 1
...@@ -35,7 +35,7 @@ class Constants: ...@@ -35,7 +35,7 @@ class Constants:
def build_json_feature(features=None,**kwargs): def build_json_feature(features=None,code=None,**kwargs):
if features == None: if features == None:
features = [] features = []
...@@ -44,7 +44,8 @@ def build_json_feature(features=None,**kwargs): ...@@ -44,7 +44,8 @@ def build_json_feature(features=None,**kwargs):
for key,value in kwargs.items(): for key,value in kwargs.items():
body[str(key)] = value body[str(key)] = value
ddata = dict(body,features=eval(repr(features))) ddata = {'code':code,'data':dict(subInfo = body,features=eval(repr(features)))}
return json.dumps(ddata,ensure_ascii=False) return json.dumps(ddata,ensure_ascii=False)
# businessType=int(_business_type), orderId=_orderId, loanId=_loanId,uuid = _uuid, # businessType=int(_business_type), orderId=_orderId, loanId=_loanId,uuid = _uuid,
......
...@@ -457,8 +457,6 @@ def return_LenValue(value,lens,types): ...@@ -457,8 +457,6 @@ def return_LenValue(value,lens,types):
else:return '' else:return ''
class MyThread(threading.Thread): class MyThread(threading.Thread):
def __init__(self, group=None, target=None, name=None, args=(), kwargs=None, *, daemon=None): def __init__(self, group=None, target=None, name=None, args=(), kwargs=None, *, daemon=None):
threading.Thread.__init__(self, group, target, name, args, kwargs, daemon=daemon) threading.Thread.__init__(self, group, target, name, args, kwargs, daemon=daemon)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment