Python webtest.AppError() Examples
The following are 7
code examples of webtest.AppError().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
webtest
, or try the search function
.
Example #1
Source File: test_extensions.py From tacker with Apache License 2.0 | 6 votes |
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))
Example #2
Source File: test_notify.py From squadron with MIT License | 6 votes |
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()
Example #3
Source File: recurring_tasks_test.py From clusterfuzz with Apache License 2.0 | 5 votes |
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')
Example #4
Source File: test_http.py From incubator-retired-cotton with Apache License 2.0 | 5 votes |
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')
Example #5
Source File: test_http.py From incubator-retired-cotton with Apache License 2.0 | 5 votes |
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')
Example #6
Source File: test_http.py From incubator-retired-cotton with Apache License 2.0 | 5 votes |
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')
Example #7
Source File: response_test.py From pyramid_swagger with BSD 3-Clause "New" or "Revised" License | 5 votes |
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')