|
21 | 21 | capture_event, |
22 | 22 | set_tag, |
23 | 23 | ) |
| 24 | +from sentry_sdk.spotlight import DEFAULT_SPOTLIGHT_URL |
24 | 25 | from sentry_sdk.utils import capture_internal_exception |
25 | 26 | from sentry_sdk.integrations.executing import ExecutingIntegration |
26 | 27 | from sentry_sdk.transport import Transport |
@@ -1097,6 +1098,47 @@ def test_debug_option( |
1097 | 1098 | assert "something is wrong" not in caplog.text |
1098 | 1099 |
|
1099 | 1100 |
|
| 1101 | +@pytest.mark.parametrize( |
| 1102 | + "client_option,env_var_value,spotlight_url_expected", |
| 1103 | + [ |
| 1104 | + (None, None, None), |
| 1105 | + (None, "", None), |
| 1106 | + (None, "F", None), |
| 1107 | + (False, None, None), |
| 1108 | + (False, "", None), |
| 1109 | + (False, "t", None), |
| 1110 | + (None, "t", DEFAULT_SPOTLIGHT_URL), |
| 1111 | + (None, "1", DEFAULT_SPOTLIGHT_URL), |
| 1112 | + (True, None, DEFAULT_SPOTLIGHT_URL), |
| 1113 | + (True, "http://localhost:8080/slurp", DEFAULT_SPOTLIGHT_URL), |
| 1114 | + ("http://localhost:8080/slurp", "f", "http://localhost:8080/slurp"), |
| 1115 | + (None, "http://localhost:8080/slurp", "http://localhost:8080/slurp"), |
| 1116 | + ], |
| 1117 | +) |
| 1118 | +def test_spotlight_option( |
| 1119 | + sentry_init, |
| 1120 | + monkeypatch, |
| 1121 | + client_option, |
| 1122 | + env_var_value, |
| 1123 | + spotlight_url_expected, |
| 1124 | +): |
| 1125 | + if env_var_value is None: |
| 1126 | + monkeypatch.delenv("SENTRY_SPOTLIGHT", raising=False) |
| 1127 | + else: |
| 1128 | + monkeypatch.setenv("SENTRY_SPOTLIGHT", env_var_value) |
| 1129 | + |
| 1130 | + if client_option is None: |
| 1131 | + sentry_init() |
| 1132 | + else: |
| 1133 | + sentry_init(spotlight=client_option) |
| 1134 | + |
| 1135 | + client = sentry_sdk.get_client() |
| 1136 | + url = client.spotlight.url if client.spotlight else None |
| 1137 | + assert ( |
| 1138 | + url == spotlight_url_expected |
| 1139 | + ), f"With config {client_option} and env {env_var_value}" |
| 1140 | + |
| 1141 | + |
1100 | 1142 | class IssuesSamplerTestConfig: |
1101 | 1143 | def __init__( |
1102 | 1144 | self, |
|
0 commit comments