Debian Codegraph @

tests/test_plugin_ryver.py

raw symbols SCIP
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.plugins.ryver import NotifyRyver
36
37 logging.disable(logging.CRITICAL)
38
39 # Our Testing URLs
40 apprise_url_tests = (
41 (
42 "ryver://",
43 {
44 "instance": TypeError,
45 },
46 ),
47 (
48 "ryver://:@/",
49 {
50 "instance": TypeError,
51 },
52 ),
53 (
54 "ryver://apprise",
55 {
56 # Just org provided (no token)
57 "instance": TypeError,
58 },
59 ),
60 (
61 "ryver://apprise/ckhrjW8w672m6HG?mode=invalid",
62 {
63 # invalid mode provided
64 "instance": TypeError,
65 },
66 ),
67 (
68 "ryver://x/ckhrjW8w672m6HG?mode=slack",
69 {
70 # Invalid org
71 "instance": TypeError,
72 },
73 ),
74 (
75 "ryver://apprise/ckhrjW8w672m6HG?mode=slack",
76 {
77 # No username specified; this is still okay as we use whatever
78 # the user told the webhook to use; set our slack mode
79 "instance": NotifyRyver,
80 },
81 ),
82 (
83 "ryver://apprise/ckhrjW8w672m6HG?mode=ryver",
84 {
85 # No username specified; this is still okay as we use whatever
86 # the user told the webhook to use; set our ryver mode
87 "instance": NotifyRyver,
88 },
89 ),
90 # Legacy webhook mode setting:
91 # Legacy webhook mode setting:
92 (
93 "ryver://apprise/ckhrjW8w672m6HG?webhook=slack",
94 {
95 # No username specified; this is still okay as we use whatever
96 # the user told the webhook to use; set our slack mode
97 "instance": NotifyRyver,
98 },
99 ),
100 (
101 "ryver://apprise/ckhrjW8w672m6HG?webhook=ryver",
102 {
103 # No username specified; this is still okay as we use whatever
104 # the user told the webhook to use; set our ryver mode
105 "instance": NotifyRyver,
106 # Our expected url(privacy=True) startswith() response:
107 "privacy_url": "ryver://apprise/c...G",
108 },
109 ),
110 # Support Native URLs
111 (
112 "https://apprise.ryver.com/application/webhook/ckhrjW8w672m6HG",
113 {
114 "instance": NotifyRyver,
115 },
116 ),
117 # Support Native URLs with arguments
118 (
119 (
120 "https://apprise.ryver.com/application/webhook/ckhrjW8w672m6HG"
121 "?webhook=ryver"
122 ),
123 {
124 "instance": NotifyRyver,
125 },
126 ),
127 (
128 "ryver://caronc@apprise/ckhrjW8w672m6HG",
129 {
130 "instance": NotifyRyver,
131 # don't include an image by default
132 "include_image": False,
133 },
134 ),
135 (
136 "ryver://apprise/ckhrjW8w672m6HG",
137 {
138 "instance": NotifyRyver,
139 # force a failure
140 "response": False,
141 "requests_response_code": requests.codes.internal_server_error,
142 },
143 ),
144 (
145 "ryver://apprise/ckhrjW8w672m6HG",
146 {
147 "instance": NotifyRyver,
148 # throw a bizarre code forcing us to fail to look it up
149 "response": False,
150 "requests_response_code": 999,
151 },
152 ),
153 (
154 "ryver://apprise/ckhrjW8w672m6HG",
155 {
156 "instance": NotifyRyver,
157 # Throws a series of i/o exceptions with this flag
158 # is set and tests that we gracefully handle them
159 "test_requests_exceptions": True,
160 },
161 ),
162 )
163
164
165 def test_plugin_ryver_urls():
166 """NotifyRyver() Apprise URLs."""
167
168 # Run our general tests
169 AppriseURLTester(tests=apprise_url_tests).run_all()
170
171
172 def test_plugin_ryver_edge_cases():
173 """NotifyRyver() Edge Cases."""
174
175 # No token
176 with pytest.raises(TypeError):
177 NotifyRyver(organization="abc", token=None)
178
179 with pytest.raises(TypeError):
180 NotifyRyver(organization="abc", token=" ")
181
182 # No organization
183 with pytest.raises(TypeError):
184 NotifyRyver(organization=None, token="abc")
185
186 with pytest.raises(TypeError):
187 NotifyRyver(organization=" ", token="abc")