Open
Conversation
elfjes
suggested changes
Jun 3, 2025
Contributor
elfjes
left a comment
There was a problem hiding this comment.
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
elfjes
approved these changes
Jun 9, 2025
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", | ||
| ), | ||
| ], | ||
| ) |
Contributor
There was a problem hiding this comment.
Ha, I had never considered that it was possbile to have multple pytest.mark.parametrize decorators. pretty nifty :D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira: DBOARD3-1165
Depends on and adds support for: Uninett/Argus#1497