本文整理汇总了Python中webtest.AppError方法的典型用法代码示例。如果您正苦于以下问题:Python webtest.AppError方法的具体用法?Python webtest.AppError怎么用?Python webtest.AppError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webtest
的用法示例。
在下文中一共展示了webtest.AppError方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_exceptions_notimplemented
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import AppError [as 别名]
def test_exceptions_notimplemented(self):
controller = self.ResourceExtensionController()
member = {'notimplemented_function': "GET"}
res_ext = extensions.ResourceExtension('tweedles', controller,
member_actions=member)
test_app = _setup_extensions_test_app(SimpleExtensionManager(res_ext))
# Ideally we would check for a 501 code here but webtest doesn't take
# anything that is below 200 or above 400 so we can't actually check
# it. It throws webtest.AppError instead.
try:
test_app.get("/tweedles/some_id/notimplemented_function")
# Shouldn't be reached
self.assertTrue(False)
except webtest.AppError as e:
self.assertIn('501', str(e))
示例2: test_application
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import AppError [as 别名]
def test_application():
called = threading.Event()
callback = lambda x: called.set()
username = 'user'
password = 'pass'
wh = webhook.WebHookHandler(username, password, callback, None)
app = TestApp(wh.application)
resp = app.post_json('/', {'head_commit':{'commit':'id'}},
headers={'Authorization':make_auth_header(username,password)})
assert resp.status_int == 200
assert resp.normal_body == 'OK'
assert called.is_set()
called.clear()
with pytest.raises(AppError) as ex:
resp = app.post_json('/', {'head_commit':{'commit':'id'}})
assert not called.is_set()
示例3: test_execute
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import AppError [as 别名]
def test_execute(self):
"""Tests that we don't directly use this scheduler."""
with self.assertRaises(webtest.AppError):
self.app.get('/schedule-open-reproducible-testcase-tasks')
示例4: test_create_cluster_exists
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import AppError [as 别名]
def test_create_cluster_exists(self):
self._scheduler.set_exception(MysosScheduler.ClusterExists())
with pytest.raises(AppError) as e:
assert self._app.post('/clusters/test_cluster', {'num_nodes': 3, 'cluster_user': 'mysos'})
assert e.value.message.startswith('Bad response: 409')
示例5: test_create_cluster_value_error
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import AppError [as 别名]
def test_create_cluster_value_error(self):
self._scheduler.set_exception(ValueError())
with pytest.raises(AppError) as e:
self._app.post('/clusters/test_cluster', {'num_nodes': 3, 'cluster_user': 'mysos'})
assert e.value.message.startswith('Bad response: 400')
示例6: test_create_cluster_invalid_user
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import AppError [as 别名]
def test_create_cluster_invalid_user(self):
self._scheduler.set_exception(MysosScheduler.InvalidUser())
with pytest.raises(AppError) as e:
self._app.post('/clusters/test_cluster', {'num_nodes': 3, 'cluster_user': 'mysos'})
assert e.value.message.startswith('Bad response: 400')
示例7: test_app_error_if_path_not_in_spec_and_path_validation_disabled
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import AppError [as 别名]
def test_app_error_if_path_not_in_spec_and_path_validation_disabled():
"""If path missing and validation is disabled we want to let something else
handle the error. TestApp throws an AppError, but Pyramid would throw a
HTTPNotFound exception.
"""
with pytest.raises(AppError):
app = build_test_app(
swagger_versions=['1.2'],
**{'pyramid_swagger.enable_path_validation': False}
)
assert app.get('/this/path/doesnt/exist')