コード例 #1
0
ファイル: test_integration.py プロジェクト: Kayle009/sentry
class IntegrationEndpointTest(APITestCase):

    def setUp(self):
        self.endpoint = IntegrationEndpoint()

    def test_handle_exception(self):
        exc = APIException('There was a problem!')
        exc.status_code = 400  # set the status code to 400 not possible to set in init
        exc.code = 400  # rest framework APIError is not compatible with integration APIError exception type
        resp = self.endpoint.handle_exception(HttpRequest(), exc)
        assert resp.status_code == 400
        assert resp.exception is True

    def test_handle_exception_503(self):
        resp = IntegrationEndpoint().handle_exception(HttpRequest(), ApiError('This is an error', code=503))
        assert resp.status_code == 503
        assert resp.exception is True

    def test_handle_exception_stdlib(self):
        resp = IntegrationEndpoint().handle_exception(
            HttpRequest(),
            ValueError('This is an error')
        )
        assert resp.status_code == 500
        assert resp.exception is True
コード例 #2
0
ファイル: test_integration.py プロジェクト: Kayle009/sentry
 def setUp(self):
     self.endpoint = IntegrationEndpoint()
コード例 #3
0
 def test_handle_exception_503(self):
     resp = IntegrationEndpoint().handle_exception(
         HttpRequest(), ApiError("This is an error", code=503))
     assert resp.status_code == 503
     assert resp.exception is True