Skip to content

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
Contributor

@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
Contributor

@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
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