-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, looks good 👍
@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", | ||
), | ||
], | ||
) |
There was a problem hiding this comment.
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
Jira: DBOARD3-1165
Depends on and adds support for: Uninett/Argus#1497