|
19 | 19 | capture_event, |
20 | 20 | set_tag, |
21 | 21 | ) |
| 22 | +from sentry_sdk.spotlight import DEFAULT_SPOTLIGHT_URL |
22 | 23 | from sentry_sdk.utils import capture_internal_exception |
23 | 24 | from sentry_sdk.integrations.executing import ExecutingIntegration |
24 | 25 | from sentry_sdk.transport import Transport |
@@ -1047,6 +1048,47 @@ def test_debug_option( |
1047 | 1048 | assert "something is wrong" not in caplog.text |
1048 | 1049 |
|
1049 | 1050 |
|
| 1051 | +@pytest.mark.parametrize( |
| 1052 | + "client_option,env_var_value,spotlight_url_expected", |
| 1053 | + [ |
| 1054 | + (None, None, None), |
| 1055 | + (None, "", None), |
| 1056 | + (None, "F", None), |
| 1057 | + (False, None, None), |
| 1058 | + (False, "", None), |
| 1059 | + (False, "t", None), |
| 1060 | + (None, "t", DEFAULT_SPOTLIGHT_URL), |
| 1061 | + (None, "1", DEFAULT_SPOTLIGHT_URL), |
| 1062 | + (True, None, DEFAULT_SPOTLIGHT_URL), |
| 1063 | + (True, "http://localhost:8080/slurp", DEFAULT_SPOTLIGHT_URL), |
| 1064 | + ("http://localhost:8080/slurp", "f", "http://localhost:8080/slurp"), |
| 1065 | + (None, "http://localhost:8080/slurp", "http://localhost:8080/slurp"), |
| 1066 | + ], |
| 1067 | +) |
| 1068 | +def test_spotlight_option( |
| 1069 | + sentry_init, |
| 1070 | + monkeypatch, |
| 1071 | + client_option, |
| 1072 | + env_var_value, |
| 1073 | + spotlight_url_expected, |
| 1074 | +): |
| 1075 | + if env_var_value is None: |
| 1076 | + monkeypatch.delenv("SENTRY_SPOTLIGHT", raising=False) |
| 1077 | + else: |
| 1078 | + monkeypatch.setenv("SENTRY_SPOTLIGHT", env_var_value) |
| 1079 | + |
| 1080 | + if client_option is None: |
| 1081 | + sentry_init() |
| 1082 | + else: |
| 1083 | + sentry_init(spotlight=client_option) |
| 1084 | + |
| 1085 | + client = sentry_sdk.get_client() |
| 1086 | + url = client.spotlight.url if client.spotlight else None |
| 1087 | + assert ( |
| 1088 | + url == spotlight_url_expected |
| 1089 | + ), f"With config {client_option} and env {env_var_value}" |
| 1090 | + |
| 1091 | + |
1050 | 1092 | class IssuesSamplerTestConfig: |
1051 | 1093 | def __init__( |
1052 | 1094 | self, |
|
0 commit comments