Skip to content

Commit 28f9997

Browse files
olevskileafty
andauthored
chore: fix failing tests (#1224)
Co-authored-by: Flora Thiebaut <flora.thiebaut@sdsc.ethz.ch>
1 parent 363203a commit 28f9997

2 files changed

Lines changed: 0 additions & 32 deletions

File tree

test/bases/renku_data_services/data_api/conftest.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
from copy import deepcopy
66
from datetime import timedelta
77
from typing import Any, Protocol
8-
from unittest.mock import MagicMock
98

109
import pytest
1110
import pytest_asyncio
12-
import sentry_sdk
1311
from authzed.api.v1 import Relationship, RelationshipUpdate, SubjectReference, WriteRelationshipsRequest
1412
from httpx import Response
1513
from sanic import Sanic
@@ -864,11 +862,3 @@ async def amalthea_session_k8s_watcher(cluster, amalthea_installation, app_manag
864862
yield
865863
with contextlib.suppress(TimeoutError):
866864
await watcher.stop(timeout=timedelta(seconds=1))
867-
868-
869-
@pytest.fixture
870-
def dummy_sentry():
871-
client = sentry_sdk.Client(dsn="https://dummy@sentry.dsn/42", transport=MagicMock(), traces_sample_rate=0.0)
872-
873-
with sentry_sdk.hub.Hub(client):
874-
yield

test/bases/renku_data_services/data_api/test_error_handler.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import inspect
2-
import re
32
from collections.abc import Awaitable, Callable
43
from typing import Any
54

@@ -117,24 +116,3 @@ def test_error_handler(err: Exception | Callable, expected_response: dict[str, A
117116
_, res = test_client.get("/")
118117
assert res.status_code == expected_status_code
119118
assert res.json == expected_response
120-
121-
122-
def test_sentry_trace_id_is_included_in_errors(dummy_sentry):
123-
app = Sanic("test-error-handler")
124-
app.error_handler = CustomErrorHandler(apispec)
125-
app.get("/")(_trigger_error(Exception("test"))) # type: ignore[unused-coroutine]
126-
test_client = SanicTestClient(app)
127-
128-
_, response = test_client.get("/")
129-
130-
assert response.status_code == 500
131-
# trace_id is included in the error response and is a UUID
132-
assert "trace_id" in response.json["error"]
133-
assert re.match(r"^[0-9a-fA-F]{32}$", response.json["error"]["trace_id"])
134-
135-
# Set a specific trace_id
136-
trace_id = "4bf92f3577b34da6a3ce929d0e0e4736"
137-
_, response = test_client.get("/", headers={"sentry-trace": f"{trace_id}-0123456789abcdef-0"})
138-
139-
assert response.status_code == 500
140-
assert response.json["error"]["trace_id"] == trace_id

0 commit comments

Comments
 (0)