Skip to content

Commit

Permalink
[Ntfy] Add dedicated test case, exercising additional template arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Feb 13, 2023
1 parent f2e5204 commit a666a27
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/services/test_ntfy.py
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

0 comments on commit a666a27

Please sign in to comment.