Debian Codegraph @

tests/test_plugin_xbmc_kodi.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 requests
33
34 from apprise import NotifyType
35 from apprise.plugins.kodi import NotifyXBMC
36
37 logging.disable(logging.CRITICAL)
38
39 # Our Testing URLs
40 apprise_url_tests = (
41 (
42 "kodi://",
43 {
44 "instance": None,
45 },
46 ),
47 (
48 "kodis://",
49 {
50 "instance": None,
51 },
52 ),
53 (
54 "kodi://localhost",
55 {
56 "instance": NotifyXBMC,
57 },
58 ),
59 (
60 "kodi://192.168.4.1",
61 {
62 # Support IPv4 Addresses
63 "instance": NotifyXBMC,
64 },
65 ),
66 (
67 "kodi://[2001:db8:002a:3256:adfe:05c0:0003:0006]",
68 {
69 # Support IPv6 Addresses
70 "instance": NotifyXBMC,
71 # Privacy URL
72 "privacy_url": "kodi://[2001:db8:002a:3256:adfe:05c0:0003:0006]",
73 },
74 ),
75 (
76 "kodi://[2001:db8:002a:3256:adfe:05c0:0003:0006]:8282",
77 {
78 # Support IPv6 Addresses with port
79 "instance": NotifyXBMC,
80 # Privacy URL
81 "privacy_url": (
82 "kodi://[2001:db8:002a:3256:adfe:05c0:0003:0006]:8282"
83 ),
84 },
85 ),
86 (
87 "kodi://user:pass@localhost",
88 {
89 "instance": NotifyXBMC,
90 # Our expected url(privacy=True) startswith() response:
91 "privacy_url": "kodi://user:****@localhost",
92 },
93 ),
94 (
95 "kodi://localhost:8080",
96 {
97 "instance": NotifyXBMC,
98 },
99 ),
100 (
101 "kodi://user:pass@localhost:8080",
102 {
103 "instance": NotifyXBMC,
104 },
105 ),
106 (
107 "kodis://localhost",
108 {
109 "instance": NotifyXBMC,
110 },
111 ),
112 (
113 "kodis://user:pass@localhost",
114 {
115 "instance": NotifyXBMC,
116 },
117 ),
118 (
119 "kodis://localhost:8080/path/",
120 {
121 "instance": NotifyXBMC,
122 },
123 ),
124 (
125 "kodis://user:password@localhost:8080",
126 {
127 "instance": NotifyXBMC,
128 # Our expected url(privacy=True) startswith() response:
129 "privacy_url": "kodis://user:****@localhost:8080",
130 },
131 ),
132 (
133 "kodi://localhost",
134 {
135 "instance": NotifyXBMC,
136 # Experement with different notification types
137 "notify_type": NotifyType.WARNING,
138 },
139 ),
140 (
141 "kodi://localhost",
142 {
143 "instance": NotifyXBMC,
144 # Experement with different notification types
145 "notify_type": NotifyType.FAILURE,
146 },
147 ),
148 (
149 "kodis://localhost:443",
150 {
151 "instance": NotifyXBMC,
152 # don't include an image by default
153 "include_image": False,
154 },
155 ),
156 (
157 "kodi://:@/",
158 {
159 "instance": None,
160 },
161 ),
162 (
163 "kodi://user:pass@localhost:8081",
164 {
165 "instance": NotifyXBMC,
166 # force a failure
167 "response": False,
168 "requests_response_code": requests.codes.internal_server_error,
169 },
170 ),
171 (
172 "kodi://user:pass@localhost:8082",
173 {
174 "instance": NotifyXBMC,
175 # throw a bizarre code forcing us to fail to look it up
176 "response": False,
177 "requests_response_code": 999,
178 },
179 ),
180 (
181 "kodi://user:pass@localhost:8083",
182 {
183 "instance": NotifyXBMC,
184 # Throws a series of i/o exceptions with this flag
185 # is set and tests that we gracefully handle them
186 "test_requests_exceptions": True,
187 },
188 ),
189 #
190 # XMBC (Legacy Platform) Shares this same KODI Plugin
191 #
192 (
193 "xbmc://",
194 {
195 "instance": None,
196 },
197 ),
198 (
199 "xbmc://localhost",
200 {
201 "instance": NotifyXBMC,
202 },
203 ),
204 (
205 "xbmc://localhost?duration=14",
206 {
207 "instance": NotifyXBMC,
208 },
209 ),
210 (
211 "xbmc://localhost?duration=invalid",
212 {
213 "instance": NotifyXBMC,
214 },
215 ),
216 (
217 "xbmc://localhost?duration=-1",
218 {
219 "instance": NotifyXBMC,
220 },
221 ),
222 (
223 "xbmc://user:pass@localhost",
224 {
225 "instance": NotifyXBMC,
226 },
227 ),
228 (
229 "xbmc://localhost:8080",
230 {
231 "instance": NotifyXBMC,
232 },
233 ),
234 (
235 "xbmc://user:pass@localhost:8080",
236 {
237 "instance": NotifyXBMC,
238 },
239 ),
240 (
241 "xbmc://user@localhost",
242 {
243 "instance": NotifyXBMC,
244 # don't include an image by default
245 "include_image": False,
246 },
247 ),
248 (
249 "xbmc://localhost",
250 {
251 "instance": NotifyXBMC,
252 # Experement with different notification types
253 "notify_type": NotifyType.WARNING,
254 },
255 ),
256 (
257 "xbmc://localhost",
258 {
259 "instance": NotifyXBMC,
260 # Experement with different notification types
261 "notify_type": NotifyType.FAILURE,
262 },
263 ),
264 (
265 "xbmc://:@/",
266 {
267 "instance": None,
268 },
269 ),
270 (
271 "xbmc://user:pass@localhost:8081",
272 {
273 "instance": NotifyXBMC,
274 # force a failure
275 "response": False,
276 "requests_response_code": requests.codes.internal_server_error,
277 },
278 ),
279 (
280 "xbmc://user:pass@localhost:8082",
281 {
282 "instance": NotifyXBMC,
283 # throw a bizarre code forcing us to fail to look it up
284 "response": False,
285 "requests_response_code": 999,
286 },
287 ),
288 (
289 "xbmc://user:pass@localhost:8083",
290 {
291 "instance": NotifyXBMC,
292 # Throws a series of i/o exceptions with this flag
293 # is set and tests that we gracefully handle them
294 "test_requests_exceptions": True,
295 },
296 ),
297 )
298
299
300 def test_plugin_xbmc_kodi_urls():
301 """NotifyXBMC() Apprise URLs."""
302
303 # Run our general tests
304 AppriseURLTester(tests=apprise_url_tests).run_all()