Skip to content

Improve bulk action error handling#113

Open
jladd-geant wants to merge 8 commits into
developfrom
FEATURE/DBOARD3-1165
Open

Improve bulk action error handling#113
jladd-geant wants to merge 8 commits into
developfrom
FEATURE/DBOARD3-1165

Conversation

@jladd-geant

@jladd-geant jladd-geant commented Jun 2, 2025

Copy link
Copy Markdown
Collaborator

Jira: DBOARD3-1165
Depends on and adds support for: Uninett/Argus#1497

@jladd-geant jladd-geant changed the title DBOARD3-1165 Improve bulk action error handling Jun 2, 2025

@elfjes elfjes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I like how you check for errors. I have some comments below, mainly related to the wording of messages.

It would also be nice if you could add some unittests. For example to test the bulk_action_require_write decorator and to test if messages are received by the messages framework

Comment thread src/geant_argus/geant_argus/incidents/bulk_actions.py Outdated
Comment thread src/geant_argus/geant_argus/dashboard_alarms.py Outdated
Comment thread src/geant_argus/geant_argus/incidents/bulk_actions.py Outdated
@jladd-geant jladd-geant requested a review from elfjes June 9, 2025 11:01

@elfjes elfjes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, looks good 👍

Comment thread test/test_bulk_actions.py
Comment on lines +283 to +315
@pytest.mark.parametrize(
"status_code, expected_message_template",
[
(
# Custom message
400,
"API error while {message} with ID 12345: "
"Bad request, alarm may be pending (HTTP 400)",
),
(
# No custom message
418,
"API error while {message} with ID 12345: "
"Server refuses to brew coffee because it is a teapot. (HTTP 418)",
),
],
)
@pytest.mark.parametrize(
"mock_qs, bulk_func, custom_message",
[
(bulk_close_incidents_mock_qs(), bulk_close_incidents, "closing incident"),
(
[MagicMock(metadata={"status": "ACTIVE", "endpoints": {}}, source_incident_id=12345)],
bulk_clear_incidents,
"clearing incident",
),
(
[MagicMock(metadata={"status": "ACTIVE", "endpoints": {}}, source_incident_id=12345)],
bulk_update_ticket_ref,
"updating ticket_ref for incident",
),
],
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, I had never considered that it was possbile to have multple pytest.mark.parametrize decorators. pretty nifty :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants