标签:参数说明 baidu rect get amp time main ddd pytho
#coding:utf-8
from mock import mock
#模拟mock 封装
def mock_test(mock_method,request_data,url,method,response_data):
mock_method = mock.Mock(return_value=response_data)
res = mock_method(url,method,request_data)
return res
参数说明:
mock_method:封装的方法名
request_data,方法的请求数据
url:方法使用的url
method:方法的请求方式:POST,GET
response_data:需要mock模拟返回的结果
具体应用可以如下:
url = ‘https://xxxx‘
repquest_data = {
‘timestamp‘:‘1507034803124‘,
‘uid‘:‘5249191‘,
‘uuid‘:‘5ae7d1a22c82fb89c78f603420870ad7‘,
‘secrect‘:‘078474b41dd37ddd5efeb04aa591ec12‘,
‘token‘:‘7d6f14f21ec96d755de41e6c076758dd‘,
‘cid‘:‘0‘,
‘errorCode‘:1001
}
response_data = {
‘code‘:‘200‘
‘msg‘:‘success‘
}
#res = self.run.run_main(url,‘POST‘,data)
res = mock_test(run.run_main,repquest_data,url,"POST",data)
标签:参数说明 baidu rect get amp time main ddd pytho
原文地址:https://www.cnblogs.com/fppblog/p/11136936.html