Skip to content

Improve bulk action error handling #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

jladd-geant
Copy link
Collaborator

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

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
Copy link
Collaborator

@elfjes elfjes left a comment

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

@jladd-geant jladd-geant requested a review from elfjes June 9, 2025 11:01
Copy link
Collaborator

@elfjes elfjes left a comment

Choose a reason for hiding this comment

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

nice, looks good 👍

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
Collaborator

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