Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cases added to support Recent Home Assistant Pull Request #1064

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,58 @@ def apprise_test(do_notify):

# Clear our server listings again
a.clear()
assert len(a) == 0

# No servers to notify
assert do_notify(a, title="my title", body="my body") is False

# More Variations of Multiple Adding of URLs
a = Apprise()
assert a.add(servers)
assert len(a) == 2
a.clear()

assert a.add('ntfys://user:pass@host/test, json://localhost')
assert len(a) == 2
a.clear()

assert a.add(['ntfys://user:pass@host/test', 'json://localhost'])
assert len(a) == 2
a.clear()

assert a.add(('ntfys://user:pass@host/test', 'json://localhost'))
assert len(a) == 2
a.clear()

assert a.add(set(['ntfys://user:pass@host/test', 'json://localhost']))
assert len(a) == 2
a.clear()

# Pass a list entry containing 1 string with 2 elements in it
# Mimic Home-Assistant core-2024.2.1 Issue:
# - https://github.com/home-assistant/core/issues/110242
#
# In this case, the first one will load, but not the second entry
# This is by design; but captured here to illustrate the issue
assert a.add(['ntfys://user:pass@host/test, json://localhost'])
assert len(a) == 1
assert a[0].url().startswith('ntfys://')
a.clear()

# Following thorugh with the problem of providing a list containing
# an entry with 2 URLs in it... while the ntfys parsed okay above,
# the same can't be said for other combinations. It's important
# to always keep strings separately
assert a.add(['mailto://user:pass@example.com, json://localhost']) is False
assert len(a) == 0

# Showing that the URLs were valid on their own:
assert a.add(*['mailto://user:pass@example.com, json://localhost'])
assert len(a) == 2
assert a[0].url().startswith('mailto://')
assert a[1].url().startswith('json://')
a.clear()

class BadNotification(NotifyBase):
def __init__(self, **kwargs):
super().__init__(**kwargs)
Expand Down
Loading