From a1b1faae3c6c774636de849dfae3535ca4795168 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Tue, 13 Aug 2019 17:52:30 +0200 Subject: [PATCH] test: Add test for Flask class-based views --- tests/integrations/flask/test_flask.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/integrations/flask/test_flask.py b/tests/integrations/flask/test_flask.py index 8d411a159b..e1e88bc82b 100644 --- a/tests/integrations/flask/test_flask.py +++ b/tests/integrations/flask/test_flask.py @@ -6,6 +6,7 @@ flask = pytest.importorskip("flask") from flask import Flask, Response, request, abort, stream_with_context +from flask.views import View from flask_login import LoginManager, login_user @@ -554,3 +555,25 @@ def zerodivision(e): assert response.status_code == 200 assert not events + + +def test_class_based_views(sentry_init, app, capture_events): + sentry_init(integrations=[flask_sentry.FlaskIntegration()]) + events = capture_events() + + @app.route("/") + class HelloClass(View): + def dispatch_request(self): + capture_message("hi") + return "ok" + + app.add_url_rule("/hello-class/", view_func=HelloClass.as_view("hello_class")) + + with app.test_client() as client: + response = client.get("/hello-class/") + assert response.status_code == 200 + + event, = events + + assert event["message"] == "hi" + assert event['transaction'] == 'hello_class'