Skip to content

Commit 6bb6b2d

Browse files
committed
Add MockSentryTransport for testing Sentry configurations
1 parent e27bcea commit 6bb6b2d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/conftest.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import litestar
77
import pytest
8+
from sentry_sdk.transport import Transport as SentryTransport
89

910
import microbootstrap.settings
1011
from microbootstrap import (
@@ -22,6 +23,10 @@
2223
from microbootstrap.settings import BaseServiceSettings, ServerConfig
2324

2425

26+
if typing.TYPE_CHECKING:
27+
from sentry_sdk.envelope import Envelope as SentryEnvelope
28+
29+
2530
pytestmark = [pytest.mark.anyio]
2631

2732

@@ -35,9 +40,17 @@ def default_litestar_app() -> litestar.Litestar:
3540
return litestar.Litestar()
3641

3742

43+
class MockSentryTransport(SentryTransport):
44+
def capture_envelope(self, envelope: SentryEnvelope) -> None: ...
45+
46+
3847
@pytest.fixture
3948
def minimal_sentry_config() -> SentryConfig:
40-
return SentryConfig(sentry_dsn="https://[email protected]/0", sentry_tags={"test": "test"})
49+
return SentryConfig(
50+
sentry_dsn="https://[email protected]/0",
51+
sentry_tags={"test": "test"},
52+
sentry_additional_params={"transport": MockSentryTransport()},
53+
)
4154

4255

4356
@pytest.fixture

0 commit comments

Comments
 (0)