本文整理汇总了Python中WMQuality.WebTools.RESTServerSetup.DefaultConfig.getModelConfig方法的典型用法代码示例。如果您正苦于以下问题:Python DefaultConfig.getModelConfig方法的具体用法?Python DefaultConfig.getModelConfig怎么用?Python DefaultConfig.getModelConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMQuality.WebTools.RESTServerSetup.DefaultConfig
的用法示例。
在下文中一共展示了DefaultConfig.getModelConfig方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RESTTest
# 需要导入模块: from WMQuality.WebTools.RESTServerSetup import DefaultConfig [as 别名]
# 或者: from WMQuality.WebTools.RESTServerSetup.DefaultConfig import getModelConfig [as 别名]
#.........这里部分代码省略.........
urllib_data = urllib.urlopen(url)
if self.do_production:
#production mode returns 403 error
self.assertEquals(urllib_data.getcode(), 403)
else:
response_data = urllib_data.read()
response_data = json.loads(response_data)
self.assertEquals(response_data['type'], expected_data['type'])
self.assertEquals(response_data['message'], expected_data['message'])
self.assertEquals(urllib_data.getcode(), 400)
def testList(self):
verb ='GET'
url = self.urlbase + 'list/'
request_input = {'input_int':123, 'input_str':'abc'}
output={'code':200, 'type':'text/json'}
result = json.loads(methodTest(verb, url, request_input=request_input, output=output)[0])
for i in result.keys():
self.assertEqual(result[i], request_input[i], '%s does not match response' % i)
def testA(self):
for t in ['GET', 'POST', 'PUT', 'DELETE', 'UPDATE']:
response = makeRequest(url=self.urlbase + '/', values={'value':1234})
assert response[1] == 200, 'Got a return code != 200 (got %s)' % response[1]
def testSanitisePass(self):
"""
Emulate how CherryPy passes arguments to a method, check that the data
returned is correct.
No server setup required
"""
drm = DummyRESTModel(self.config.getModelConfig())
def func(*args, **kwargs):
sanitised_input = drm._sanitise_input(args, kwargs, "list")
return drm.list(**sanitised_input)
# 2 positional args (e.g. url/arg1/arg2)
result = func(123, 'abc')
assert result == {'input_int':123, 'input_str':'abc'},\
'list with 2 positional args failed: %s' % result
# 2 query string args (e.g. url?int=arg1&str=arg2)
result = func(input_int=123, input_str='abc')
assert result == {'input_int':123, 'input_str':'abc'},\
'list with 2 query string args failed: %s' % result
# 1 positional, 1 keyword (e.g. url/arg1/?str=arg2)
result = func(123, input_str='abc')
assert result == {'input_int':123, 'input_str':'abc'},\
'list with 1 positional, 1 keyword failed: %s' % result
def testSanitisePassHTTP(self):
"""
Same as testSanitisePass but do it over http and check the returned http
codes.
"""
# 2 positional args (e.g. url/arg1/arg2)
url = self.urlbase + 'list/123/abc'
response = makeRequest(url=url)
assert response[1] == 200, \
'list with 2 positional args failed: ' +\
'. Got a return code != 200 (got %s)' % response[1] +\
'. Returned data: %s' % response[0]
# 2 query string args (e.g. url?int=arg1&str=arg2)