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 43 44 45 46 47
|
from unittest.mock import MagicMock, patch
import pytest
@pytest.mark.forked
def test_integration_enabled_if_option_is_on(sentry_init, reset_integrations):
mocked_setup_once = MagicMock()
with patch(
"sentry_sdk.integrations.opentelemetry.integration.OpenTelemetryIntegration.setup_once",
mocked_setup_once,
):
sentry_init(
_experiments={
"otel_powered_performance": True,
},
)
mocked_setup_once.assert_called_once()
@pytest.mark.forked
def test_integration_not_enabled_if_option_is_off(sentry_init, reset_integrations):
mocked_setup_once = MagicMock()
with patch(
"sentry_sdk.integrations.opentelemetry.integration.OpenTelemetryIntegration.setup_once",
mocked_setup_once,
):
sentry_init(
_experiments={
"otel_powered_performance": False,
},
)
mocked_setup_once.assert_not_called()
@pytest.mark.forked
def test_integration_not_enabled_if_option_is_missing(sentry_init, reset_integrations):
mocked_setup_once = MagicMock()
with patch(
"sentry_sdk.integrations.opentelemetry.integration.OpenTelemetryIntegration.setup_once",
mocked_setup_once,
):
sentry_init()
mocked_setup_once.assert_not_called()
|