| 1 |
# BSD 2-Clause License |
| 2 |
# |
| 3 |
# Apprise - Push Notification Library. |
| 4 |
# Copyright (c) 2026, Chris Caron <[email protected]> |
| 5 |
# |
| 6 |
# Redistribution and use in source and binary forms, with or without |
| 7 |
# modification, are permitted provided that the following conditions are met: |
| 8 |
# |
| 9 |
# 1. Redistributions of source code must retain the above copyright notice, |
| 10 |
# this list of conditions and the following disclaimer. |
| 11 |
# |
| 12 |
# 2. Redistributions in binary form must reproduce the above copyright notice, |
| 13 |
# this list of conditions and the following disclaimer in the documentation |
| 14 |
# and/or other materials provided with the distribution. |
| 15 |
# |
| 16 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 17 |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 19 |
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 20 |
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 |
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 |
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 23 |
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 24 |
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 25 |
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 26 |
# POSSIBILITY OF SUCH DAMAGE. |
| 27 |
|
| 28 |
# Disable logging for a cleaner testing output |
| 29 |
import logging |
| 30 |
|
| 31 |
from helpers import AppriseURLTester |
| 32 |
import pytest |
| 33 |
import requests |
| 34 |
|
| 35 |
from apprise.exception import AppriseImproperlyConfigured |
| 36 |
from apprise.plugins.ryver import NotifyRyver |
| 37 |
|
| 38 |
logging.disable(logging.CRITICAL) |
| 39 |
|
| 40 |
# Our Testing URLs |
| 41 |
apprise_url_tests = ( |
| 42 |
( |
| 43 |
"ryver://", |
| 44 |
{ |
| 45 |
"instance": AppriseImproperlyConfigured, |
| 46 |
}, |
| 47 |
), |
| 48 |
( |
| 49 |
"ryver://:@/", |
| 50 |
{ |
| 51 |
"instance": AppriseImproperlyConfigured, |
| 52 |
}, |
| 53 |
), |
| 54 |
( |
| 55 |
"ryver://apprise", |
| 56 |
{ |
| 57 |
# Just org provided (no token) |
| 58 |
"instance": AppriseImproperlyConfigured, |
| 59 |
}, |
| 60 |
), |
| 61 |
( |
| 62 |
"ryver://apprise/ckhrjW8w672m6HG?mode=invalid", |
| 63 |
{ |
| 64 |
# invalid mode provided |
| 65 |
"instance": AppriseImproperlyConfigured, |
| 66 |
}, |
| 67 |
), |
| 68 |
( |
| 69 |
"ryver://x/ckhrjW8w672m6HG?mode=slack", |
| 70 |
{ |
| 71 |
# Invalid org |
| 72 |
"instance": AppriseImproperlyConfigured, |
| 73 |
}, |
| 74 |
), |
| 75 |
( |
| 76 |
"ryver://apprise/ckhrjW8w672m6HG?mode=slack", |
| 77 |
{ |
| 78 |
# No username specified; this is still okay as we use whatever |
| 79 |
# the user told the webhook to use; set our slack mode |
| 80 |
"instance": NotifyRyver, |
| 81 |
}, |
| 82 |
), |
| 83 |
( |
| 84 |
"ryver://apprise/ckhrjW8w672m6HG?mode=ryver", |
| 85 |
{ |
| 86 |
# No username specified; this is still okay as we use whatever |
| 87 |
# the user told the webhook to use; set our ryver mode |
| 88 |
"instance": NotifyRyver, |
| 89 |
}, |
| 90 |
), |
| 91 |
# Legacy webhook mode setting: |
| 92 |
# Legacy webhook mode setting: |
| 93 |
( |
| 94 |
"ryver://apprise/ckhrjW8w672m6HG?webhook=slack", |
| 95 |
{ |
| 96 |
# No username specified; this is still okay as we use whatever |
| 97 |
# the user told the webhook to use; set our slack mode |
| 98 |
"instance": NotifyRyver, |
| 99 |
}, |
| 100 |
), |
| 101 |
( |
| 102 |
"ryver://apprise/ckhrjW8w672m6HG?webhook=ryver", |
| 103 |
{ |
| 104 |
# No username specified; this is still okay as we use whatever |
| 105 |
# the user told the webhook to use; set our ryver mode |
| 106 |
"instance": NotifyRyver, |
| 107 |
# Our expected url(privacy=True) startswith() response: |
| 108 |
"privacy_url": "ryver://apprise/c...G", |
| 109 |
}, |
| 110 |
), |
| 111 |
# Support Native URLs |
| 112 |
( |
| 113 |
"https://apprise.ryver.com/application/webhook/ckhrjW8w672m6HG", |
| 114 |
{ |
| 115 |
"instance": NotifyRyver, |
| 116 |
}, |
| 117 |
), |
| 118 |
# Support Native URLs with arguments |
| 119 |
( |
| 120 |
( |
| 121 |
"https://apprise.ryver.com/application/webhook/ckhrjW8w672m6HG" |
| 122 |
"?webhook=ryver" |
| 123 |
), |
| 124 |
{ |
| 125 |
"instance": NotifyRyver, |
| 126 |
}, |
| 127 |
), |
| 128 |
( |
| 129 |
"ryver://caronc@apprise/ckhrjW8w672m6HG", |
| 130 |
{ |
| 131 |
"instance": NotifyRyver, |
| 132 |
# don't include an image by default |
| 133 |
"include_image": False, |
| 134 |
}, |
| 135 |
), |
| 136 |
( |
| 137 |
"ryver://apprise/ckhrjW8w672m6HG", |
| 138 |
{ |
| 139 |
"instance": NotifyRyver, |
| 140 |
# force a failure |
| 141 |
"response": False, |
| 142 |
"requests_response_code": requests.codes.internal_server_error, |
| 143 |
}, |
| 144 |
), |
| 145 |
( |
| 146 |
"ryver://apprise/ckhrjW8w672m6HG", |
| 147 |
{ |
| 148 |
"instance": NotifyRyver, |
| 149 |
# throw a bizarre code forcing us to fail to look it up |
| 150 |
"response": False, |
| 151 |
"requests_response_code": 999, |
| 152 |
}, |
| 153 |
), |
| 154 |
( |
| 155 |
"ryver://apprise/ckhrjW8w672m6HG", |
| 156 |
{ |
| 157 |
"instance": NotifyRyver, |
| 158 |
# Throws a series of i/o exceptions with this flag |
| 159 |
# is set and tests that we gracefully handle them |
| 160 |
"test_requests_exceptions": True, |
| 161 |
}, |
| 162 |
), |
| 163 |
) |
| 164 |
|
| 165 |
|
| 166 |
def test_plugin_ryver_urls(): |
| 167 |
"""NotifyRyver() Apprise URLs.""" |
| 168 |
|
| 169 |
# Run our general tests |
| 170 |
AppriseURLTester(tests=apprise_url_tests).run_all() |
| 171 |
|
| 172 |
|
| 173 |
def test_plugin_ryver_edge_cases(): |
| 174 |
"""NotifyRyver() Edge Cases.""" |
| 175 |
|
| 176 |
# No token |
| 177 |
with pytest.raises(AppriseImproperlyConfigured): |
| 178 |
NotifyRyver(organization="abc", token=None) |
| 179 |
|
| 180 |
with pytest.raises(AppriseImproperlyConfigured): |
| 181 |
NotifyRyver(organization="abc", token=" ") |
| 182 |
|
| 183 |
# No organization |
| 184 |
with pytest.raises(AppriseImproperlyConfigured): |
| 185 |
NotifyRyver(organization=None, token="abc") |
| 186 |
|
| 187 |
with pytest.raises(AppriseImproperlyConfigured): |
| 188 |
NotifyRyver(organization=" ", token="abc") |