Skip to content

Commit 50ca5d3

Browse files
committed
reverted copilot comments as per the suggestion unit and integration test passed after the changes
1 parent b0c87e4 commit 50ca5d3

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

linode_api4/groups/monitor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, List, Optional
1+
from typing import Any, Optional
22

33
from linode_api4 import PaginatedList
44
from linode_api4.errors import UnexpectedResponseError
@@ -216,10 +216,10 @@ def create_alert_definition(
216216
service_type: str,
217217
label: str,
218218
severity: int,
219-
channel_ids: List[int],
219+
channel_ids: list[int],
220220
rule_criteria: Optional[dict] = None,
221221
trigger_conditions: Optional[dict] = None,
222-
entity_ids: Optional[List[str]] = None,
222+
entity_ids: Optional[list[str]] = None,
223223
description: Optional[str] = None,
224224
) -> AlertDefinition:
225225
"""

test/integration/models/monitor/test_monitor.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def test_integration_create_get_update_delete_alert_definition(
194194
try:
195195
created = client.load(AlertDefinition, created.id, service_type)
196196
except Exception:
197-
197+
# transient errors while polling; continue until timeout
198198
pass
199199

200200
if created:
@@ -206,17 +206,24 @@ def test_integration_create_get_update_delete_alert_definition(
206206
else:
207207
pytest.fail("Alert definition was not created successfully")
208208

209-
updated = client.load(AlertDefinition, update_alert.id, service_type)
210-
while (
211-
getattr(updated, "status", None) == "in progress"
212-
and (time.time() - start) < timeout
213-
):
214-
time.sleep(interval)
215-
try:
216-
updated = client.load(AlertDefinition, updated.id, service_type)
217-
except Exception:
218-
# transient errors while polling; continue until timeout
219-
pass
209+
if update_alert:
210+
updated = client.load(
211+
AlertDefinition, update_alert.id, service_type
212+
)
213+
while (
214+
getattr(updated, "status", None) == "in progress"
215+
and (time.time() - start) < timeout
216+
):
217+
time.sleep(interval)
218+
try:
219+
updated = client.load(
220+
AlertDefinition, updated.id, service_type
221+
)
222+
except Exception:
223+
# transient errors while polling; continue until timeout
224+
pass
225+
else:
226+
pytest.fail("Alert definition was not updated successfully")
220227

221228
assert created.id == updated.id
222229
assert updated.label == f"{label}-updated"
@@ -231,17 +238,12 @@ def test_integration_create_get_update_delete_alert_definition(
231238
)
232239
delete_alert.delete()
233240
except Exception:
234-
pytest.fail("Could not delete alert definition during cleanup")
241+
assert False, "Could not delete alert definition during cleanup"
235242
pass
236243

237244
# confirm it's gone (if API returns 404 or raises)
238245
try:
239246
client.load(AlertDefinition, created.id, service_type)
240-
# If no exception, fail explicitly
241-
pytest.fail("Alert definition still retrievable after delete")
242-
except ApiError:
243-
pytest.skip("Alert definition successfully deleted")
244-
pass
247+
assert False, "Alert definition still retrievable after delete"
245248
except Exception:
246-
pytest.skip("Alert definition successfully deleted")
247249
pass

0 commit comments

Comments
 (0)