当前位置: 首页>>代码示例>>Python>>正文


Python webtest.AppError方法代码示例

本文整理汇总了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)) 
开发者ID:openstack,项目名称:tacker,代码行数:18,代码来源:test_extensions.py

示例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() 
开发者ID:gosquadron,项目名称:squadron,代码行数:24,代码来源:test_notify.py

示例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') 
开发者ID:google,项目名称:clusterfuzz,代码行数:6,代码来源:recurring_tasks_test.py

示例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') 
开发者ID:apache,项目名称:incubator-retired-cotton,代码行数:8,代码来源:test_http.py

示例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') 
开发者ID:apache,项目名称:incubator-retired-cotton,代码行数:7,代码来源:test_http.py

示例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') 
开发者ID:apache,项目名称:incubator-retired-cotton,代码行数:7,代码来源:test_http.py

示例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') 
开发者ID:striglia,项目名称:pyramid_swagger,代码行数:13,代码来源:response_test.py


注:本文中的webtest.AppError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。