Skip to content

Commit 63b85e0

Browse files
committed
mock in_test_environ
1 parent 388d7ab commit 63b85e0

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

tests/sentry/seer/endpoints/test_seer_rpc.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,21 @@ def test_generic_exceptions_return_500(self) -> None:
112112
path = self._get_path("get_organization_slug")
113113
data: dict[str, Any] = {"args": {"org_id": 1}, "meta": {}}
114114

115-
with patch(
116-
"sentry.seer.endpoints.seer_rpc.SeerRpcServiceEndpoint._dispatch_to_local_method"
117-
) as mock_dispatch:
118-
mock_dispatch.side_effect = RuntimeError("Unexpected internal error")
119-
120-
response = self.client.post(
121-
path, data=data, HTTP_AUTHORIZATION=self.auth_header(path, data)
122-
)
123-
124-
assert response.status_code == 500
115+
for is_test_environment in [True, False]:
116+
with patch(
117+
"sentry.seer.endpoints.seer_rpc.in_test_environment",
118+
return_value=is_test_environment,
119+
):
120+
with patch(
121+
"sentry.seer.endpoints.seer_rpc.SeerRpcServiceEndpoint._dispatch_to_local_method"
122+
) as mock_dispatch:
123+
mock_dispatch.side_effect = RuntimeError("Unexpected internal error")
124+
125+
response = self.client.post(
126+
path, data=data, HTTP_AUTHORIZATION=self.auth_header(path, data)
127+
)
128+
129+
assert response.status_code == 500
125130

126131

127132
class TestSeerRpcMethods(APITestCase):

0 commit comments

Comments
 (0)