Skip to content

Commit f9da077

Browse files
joshuarliclaude
andcommitted
fix(tests): Fix flaky uptime alert index ordering tests
Sort both expected and actual results by ID before comparison in check_valid_response. The endpoint doesn't apply explicit ordering, so results can come back in non-deterministic order. Fixes #108890 Fixes #108884 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9b71753 commit f9da077

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎tests/sentry/uptime/endpoints/test_organization_uptime_alert_index.py‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ class OrganizationUptimeAlertIndexEndpointTest(OrganizationUptimeAlertIndexBaseE
1212
method = "get"
1313

1414
def check_valid_response(self, response, expected_detectors):
15-
assert [
16-
serialize(uptime_alert, serializer=UptimeDetectorSerializer())
17-
for uptime_alert in expected_detectors
18-
] == response.data
15+
expected = sorted(
16+
[
17+
serialize(uptime_alert, serializer=UptimeDetectorSerializer())
18+
for uptime_alert in expected_detectors
19+
],
20+
key=lambda x: x["id"],
21+
)
22+
actual = sorted(response.data, key=lambda x: x["id"])
23+
assert expected == actual
1924

2025
def test(self) -> None:
2126
alert_1 = self.create_uptime_detector(name="test1")

0 commit comments

Comments
 (0)