Skip to content

Commit 76a62af

Browse files
committed
ACLP Logs Stream - copilot review tweaks
1 parent 7544892 commit 76a62af

3 files changed

Lines changed: 17 additions & 11 deletions

File tree

linode_api4/objects/monitor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,10 +689,10 @@ def update_destinations(self, destinations: List[int]):
689689
:returns: True if the update was successful.
690690
:rtype: bool
691691
"""
692-
destination_ids = [int(dest) for dest in destinations]
693-
692+
if not destinations:
693+
raise ValueError("A destination id must be provided.")
694694
payload = {
695-
"destinations": destination_ids
695+
"destinations": destinations
696696
}
697697

698698
# The Linode API PUT request expects the flat list of IDs

test/integration/models/monitor/test_monitor_logs.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,18 @@ def test_fails_to_create_destination_empty_required_fields(test_linode_client: L
227227
def test_fails_to_create_stream_invalid_destination(test_linode_client: LinodeClient):
228228
"""
229229
Test that creating a stream with a non-existent destination ID results in a 400 ApiError.
230-
Requires no other streams to be present per account
230+
Requires no other streams to be present on account. If a stream is already present test is skipped.
231231
"""
232232
from linode_api4.errors import ApiError
233233

234+
existing_streams = test_linode_client.monitor.streams()
235+
if len(existing_streams) > 0:
236+
stream_ids = [s.id for s in existing_streams]
237+
pytest.skip(
238+
f"Skipping: existing stream(s) found on this account "
239+
f"(ID: {stream_ids}). Only one stream can be present per account. "
240+
)
241+
234242
with pytest.raises(ApiError) as excinfo:
235243
test_linode_client.monitor.stream_create(
236244
label=get_test_label(),
@@ -332,13 +340,11 @@ def test_update_stream_label(test_linode_client: LinodeClient, test_stream_activ
332340

333341
stream.label = new_label
334342
result = stream.save()
335-
336343
assert result is True
337344

338-
updated = test_linode_client.load(LogsStream, test_stream_active.id)
339-
assert updated.label == new_label
340-
341345
try:
346+
updated = test_linode_client.load(LogsStream, test_stream_active.id)
347+
assert updated.label == new_label
342348
history = updated.history
343349
snapshot_original = next(h for h in history if h.version == version_before)
344350
snapshot_updated = next(h for h in history if h.version == updated.version)
@@ -348,8 +354,8 @@ def test_update_stream_label(test_linode_client: LinodeClient, test_stream_activ
348354
assert snapshot_updated.id == test_stream_active.id
349355
finally:
350356
# Revert to original label
351-
updated.label = original_label
352-
updated.save()
357+
stream.label = original_label
358+
stream.save()
353359

354360

355361
@pytest.mark.skipif(

test/unit/objects/monitor_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ def test_fail_update_stream_destinations_when_no_destination_ids_passed(self):
489489
stream.update_destinations([])
490490

491491
self.assertFalse(m.called)
492-
assert "A Stream must have at least one destination attached." in str(
492+
assert "A destination id must be provided." in str(
493493
context.exception
494494
)
495495

0 commit comments

Comments
 (0)