Skip to content

Commit

Permalink
Add software test case for passing of more Pushover API parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Aug 21, 2022
1 parent e2b58b9 commit bfd177b
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/services/test_pushover.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,43 @@ def test_pushover_success_with_sound(srv, caplog):
assert "Successfully sent pushover notification" in caplog.text


@responses.activate
def test_pushover_success_with_html_and_url_and_url_title(srv, caplog):

module = load_module_from_file("mqttwarn/services/pushover.py")

item = Item(
config={},
target="test",
addrs=["userkey2", "appkey2"],
message="⚽ Notification message ⚽",
data={
"html": "<p>⚽ Notification message ⚽</p>",
"url": "https://example.org/foo",
"url_title": "Notification group 'foo'",
},
)

with caplog.at_level(logging.DEBUG):

add_successful_mock_response()
outcome = module.plugin(srv, item)

assert (
responses.calls[0].request.body
== "user=userkey2&token=appkey2&retry=60&expire=3600&message=%E2%9A%BD+Notification+message+%E2%9A%BD"
"&html=%3Cp%3E%E2%9A%BD+Notification+message+%E2%9A%BD%3C%2Fp%3E&url=https%3A%2F%2Fexample.org%2Ffoo"
"&url_title=Notification+group+%27foo%27"
)

assert responses.calls[0].response.status_code == 200
assert responses.calls[0].response.text == '{"status": 1}'

assert outcome is True
assert "Sending pushover notification to test" in caplog.text
assert "Successfully sent pushover notification" in caplog.text


@responses.activate
def test_pushover_success_with_devices(srv, caplog):

Expand Down

0 comments on commit bfd177b

Please sign in to comment.