當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。