Add cancel_by_tag support - #33
Open
irstmon wants to merge 1 commit into
Open
Conversation
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.
Add
cancel_by_tagsupportWhat
Adds a new
cancel_by_tag(tag)method toPushoverAPI, implementing the[cancel_by_tag receipts endpoint](https://pushover.net/api/receipts#cancel-by-tag)
of the Pushover API.
Why
The Pushover API allows attaching arbitrary tags to emergency-priority messages
via the
tagsparameter. These tags can be used to cancel all matching receiptsat once - without needing to store individual receipt IDs. This is useful for
applications like monitoring systems that may send many related emergency
notifications (e.g. per-server alerts) and want to cancel them all at once when
an issue is resolved.
Usage
Changes
src/pushover_complete/pushover_api.pyAdded
cancel_by_tag(tag)method aftercancel_receipt(). It follows theexact same pattern as the existing
cancel_receipt()method - a single callto
_generic_postwith the tag as the URL parameter:tests/PushoverAPI/test_PushoverAPI.pyAdded two new tests after the existing receipt cancel tests:
test_PushoverAPI_cancels_by_tag- verifies a successful cancel calltest_PushoverAPI_raises_error_on_bad_tag_cancel- verifies that aBadAPIRequestErroris raised when the tag has no active receiptsThe new tests import
receipt_cancel_by_tag_callbackfromresponses_callbacksand
TEST_TAGfromconstants, following the exact same structure as theexisting receipt cancel tests.
tests/responses_callbacks.pyAdded
receipt_cancel_by_tag_callbackto mock the/receipts/cancel_by_tag/{tag}.jsonendpoint. It validates the app token andchecks that the tag in the URL matches
TEST_TAG, returning a 400 errorotherwise. Also added
TEST_TAGto the imports fromtests.constants.tests/constants.pyAdded one new constant: