Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker committed Nov 21, 2024
1 parent 22d72f0 commit c612326
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
20 changes: 11 additions & 9 deletions tests/integrations/django/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ def test_ensures_x_forwarded_header_is_honored_in_sdk_when_enabled_in_django(
sentry_init(integrations=[DjangoIntegration()], send_default_pii=True)
exceptions = capture_exceptions()
events = capture_events()
unpack_werkzeug_response(client.get(reverse("view_exc"), headers={"X_FORWARDED_HOST": "example.com"}))
unpack_werkzeug_response(
client.get(reverse("view_exc"), headers={"X_FORWARDED_HOST": "example.com"})
)

(error,) = exceptions
assert isinstance(error, ZeroDivisionError)
Expand All @@ -91,7 +93,9 @@ def test_ensures_x_forwarded_header_is_not_honored_when_unenabled_in_django(
sentry_init(integrations=[DjangoIntegration()], send_default_pii=True)
exceptions = capture_exceptions()
events = capture_events()
unpack_werkzeug_response(client.get(reverse("view_exc"), headers={"X_FORWARDED_HOST": "example.com"}))
unpack_werkzeug_response(
client.get(reverse("view_exc"), headers={"X_FORWARDED_HOST": "example.com"})
)

(error,) = exceptions
assert isinstance(error, ZeroDivisionError)
Expand Down Expand Up @@ -157,9 +161,7 @@ def test_has_trace_if_performance_enabled(sentry_init, client, capture_events):
traces_sample_rate=1.0,
)
events = capture_events()
response = client.head(reverse("view_exc_with_msg"))
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
response.close()
unpack_werkzeug_response(client.head(reverse("view_exc_with_msg")))

(msg_event, error_event, transaction_event) = events

Expand Down Expand Up @@ -215,11 +217,11 @@ def test_trace_from_headers_if_performance_enabled(sentry_init, client, capture_
trace_id = "582b43a4192642f0b136d5159a501701"
sentry_trace_header = "{}-{}-{}".format(trace_id, "6e8f22c393e68f19", 1)

response = client.head(
reverse("view_exc_with_msg"), headers={"sentry-trace": sentry_trace_header}
unpack_werkzeug_response(
client.head(
reverse("view_exc_with_msg"), headers={"sentry-trace": sentry_trace_header}
)
)
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
response.close()

(msg_event, error_event, transaction_event) = events

Expand Down
4 changes: 2 additions & 2 deletions tests/integrations/flask/test_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ def test_transaction_http_method_default(
events = capture_events()

client = app.test_client()

response = client.get("/nomessage")
assert response.status_code == 200
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
Expand Down Expand Up @@ -1033,7 +1033,7 @@ def test_transaction_http_method_custom(
events = capture_events()

client = app.test_client()

response = client.get("/nomessage")
assert response.status_code == 200
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
Expand Down
20 changes: 15 additions & 5 deletions tests/integrations/strawberry/test_strawberry.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ def test_capture_request_if_available_and_send_pii_is_on(

query = "query ErrorQuery { error }"
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
client.post("/graphql", json={"query": query, "operationName": "ErrorQuery"}).close()
client.post(
"/graphql", json={"query": query, "operationName": "ErrorQuery"}
).close()

assert len(events) == 1

Expand Down Expand Up @@ -255,7 +257,9 @@ def test_do_not_capture_request_if_send_pii_is_off(

query = "query ErrorQuery { error }"
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
client.post("/graphql", json={"query": query, "operationName": "ErrorQuery"}).close()
client.post(
"/graphql", json={"query": query, "operationName": "ErrorQuery"}
).close()

assert len(events) == 1

Expand Down Expand Up @@ -336,7 +340,9 @@ def test_capture_transaction_on_error(

query = "query ErrorQuery { error }"
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
client.post("/graphql", json={"query": query, "operationName": "ErrorQuery"}).close()
client.post(
"/graphql", json={"query": query, "operationName": "ErrorQuery"}
).close()

assert len(events) == 2
(_, transaction_event) = events
Expand Down Expand Up @@ -414,7 +420,9 @@ def test_capture_transaction_on_success(

query = "query GreetingQuery { hello }"
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
client.post("/graphql", json={"query": query, "operationName": "GreetingQuery"}).close()
client.post(
"/graphql", json={"query": query, "operationName": "GreetingQuery"}
).close()

assert len(events) == 1
(transaction_event,) = events
Expand Down Expand Up @@ -725,7 +733,9 @@ def test_span_origin2(

query = "query GreetingQuery { hello }"
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
client.post("/graphql", json={"query": query, "operationName": "GreetingQuery"}).close()
client.post(
"/graphql", json={"query": query, "operationName": "GreetingQuery"}
).close()

(event,) = events

Expand Down

0 comments on commit c612326

Please sign in to comment.