How to use the webtest.AppError function in WebTest

To help you get started, we’ve selected a few WebTest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Pylons / webtest / tests / test_app.py View on Github external
def test_app_error(self):
        resp = Response(to_bytes('blah'))
        err = webtest.AppError('message %s', resp)
        self.assertEqual(err.args, ('message blah',))
github gosquadron / squadron / tests / notify / test_notify.py View on Github external
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()
github Juniper / OpenClos / tests / unit / test_rest.py View on Github external
def testGetConfigNoConfigFile(self):
        restServerTestApp = self.setupRestWithTwoDevices()

        with self.assertRaises(AppError) as e:
            restServerTestApp.get('/pods/test1/devices/test1/config')
        self.assertTrue('404 Not Found' in e.exception.message)
        self.assertTrue('Device exists but no config found' in e.exception.message)
github qdqmedia / django-templation / tests / test_webdav.py View on Github external
def test_unregistered(self):
        try:
            self.app.get('/templation/1234/')
        except AppError as e:
            self.assertTrue(e.message.startswith("Bad response: 401 Not Authorized"))
github Pylons / webtest / tests / test_app.py View on Github external
def test_app_error_misc(self):
        resp = Response(six.u('\xe9').encode('utf8'))
        resp.charset = ''
        # dont check the output. just make sure it doesn't fail
        webtest.AppError(to_bytes('message %s'), resp)
        webtest.AppError(six.u('messag\xe9 %s'), six.b('\xe9'))
github apache / incubator-retired-cotton / tests / scheduler / test_http.py View on Github external
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')
github Pylons / webtest / tests / test_app.py View on Github external
def test_check_status_none(self):
        self.assertEqual(self.check_status('200 Ok', None), None)
        self.assertRaises(webtest.AppError, self.check_status, '400 Ok')
github fsr-de / EvaP / evap / staff / tests.py View on Github external
def get_assert_403(self, url, user):
        try:
            self.app.get(url, user=user, status=403)
        except AppError as e:
            self.fail('url "{}" failed with user "{}"'.format(url, user))
github Pylons / webtest / tests / test_debugapp.py View on Github external
def test_exception(self):
        self.assertRaises(Exception, self.app.get, '/?error=t')
        self.assertRaises(webtest.AppError, self.app.get,
                          '/?status=404%20Not%20Found')