-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ntfy] Add dedicated test case, exercising additional template arguments
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2021-2023 The mqttwarn developers | ||
from unittest import mock | ||
from unittest.mock import call | ||
|
||
from mqttwarn.model import ProcessorItem as Item | ||
from mqttwarn.util import load_module_by_name | ||
|
||
|
||
@mock.patch("apprise.Apprise", create=True) | ||
@mock.patch("apprise.AppriseAsset", create=True) | ||
def test_ntfy_success(apprise_asset, apprise_mock, srv, caplog): | ||
module = load_module_by_name("mqttwarn.services.apprise_multi") | ||
|
||
item = Item( | ||
addrs=[ | ||
{ | ||
"baseuri": "ntfy://user:[email protected]/topic1/[email protected]", | ||
} | ||
], | ||
title="⚽ Message title ⚽", | ||
message="⚽ Notification message ⚽", | ||
data={"priority": "high", "tags": "foo,bar", "click": "https://httpbin.org/headers"}, | ||
) | ||
|
||
outcome = module.plugin(srv, item) | ||
|
||
assert apprise_mock.mock_calls == [ | ||
call(asset=mock.ANY), | ||
call().add( | ||
"ntfy://user:[email protected]/topic1/[email protected]" | ||
"&click=https%3A%2F%2Fhttpbin.org%2Fheaders&priority=high&tags=foo%2Cbar" | ||
), | ||
call().notify(body="⚽ Notification message ⚽", title="⚽ Message title ⚽"), | ||
call().notify().__bool__(), | ||
] | ||
|
||
assert "Successfully sent message using Apprise" in caplog.messages | ||
assert outcome is True |