Skip to content

Commit

Permalink
test: Add test for Flask class-based views
Browse files Browse the repository at this point in the history
  • Loading branch information
untitaker committed Aug 13, 2019
1 parent fed714a commit a1b1faa
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/integrations/flask/test_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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'

0 comments on commit a1b1faa

Please sign in to comment.