-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sentry_instrument.py
More file actions
42 lines (28 loc) · 1020 Bytes
/
test_sentry_instrument.py
File metadata and controls
42 lines (28 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import logging
import typing
import pytest
import sentry_sdk
from tests.conftest import SentryTestTransport
if typing.TYPE_CHECKING:
pass
from lite_bootstrap.instruments.sentry_instrument import (
SentryConfig,
SentryInstrument,
)
logger = logging.getLogger(__name__)
@pytest.fixture
def minimal_sentry_config(sentry_mock: SentryTestTransport) -> SentryConfig:
return SentryConfig(
sentry_dsn="https://testdsn@localhost/1",
sentry_tags={"test": "test"},
sentry_additional_params={"transport": sentry_mock},
)
def test_sentry_instrument_with_raise(minimal_sentry_config: SentryConfig, sentry_mock: SentryTestTransport) -> None:
SentryInstrument(bootstrap_config=minimal_sentry_config).bootstrap()
try:
logger.error("some error")
assert len(sentry_mock.mock_envelopes) == 1
finally:
sentry_sdk.init()
def test_sentry_instrument_empty_dsn() -> None:
SentryInstrument(bootstrap_config=SentryConfig(sentry_dsn="")).bootstrap()