Debian Codegraph @

tests/test_plugin_enigma2.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.plugins.enigma2 import NotifyEnigma2
35
36 logging.disable(logging.CRITICAL)
37
38 # Our Testing URLs
39 apprise_url_tests = (
40 (
41 "enigma2://:@/",
42 {
43 "instance": None,
44 },
45 ),
46 (
47 "enigma2://",
48 {
49 "instance": None,
50 },
51 ),
52 (
53 "enigma2s://",
54 {
55 "instance": None,
56 },
57 ),
58 (
59 "enigma2://localhost",
60 {
61 "instance": NotifyEnigma2,
62 # This will fail because we're also expecting a server
63 # acknowledgement
64 "notify_response": False,
65 },
66 ),
67 (
68 "enigma2://localhost",
69 {
70 "instance": NotifyEnigma2,
71 # invalid JSON response
72 "requests_response_text": "{",
73 "notify_response": False,
74 },
75 ),
76 (
77 "enigma2://localhost",
78 {
79 "instance": NotifyEnigma2,
80 # False is returned
81 "requests_response_text": {"result": False},
82 "notify_response": False,
83 },
84 ),
85 (
86 "enigma2://localhost",
87 {
88 "instance": NotifyEnigma2,
89 # With the right content, this will succeed
90 "requests_response_text": {"result": True},
91 },
92 ),
93 (
94 "enigma2://user@localhost",
95 {
96 "instance": NotifyEnigma2,
97 "requests_response_text": {"result": True},
98 },
99 ),
100 # Set timeout
101 (
102 "enigma2://user@localhost?timeout=-1",
103 {
104 "instance": NotifyEnigma2,
105 "requests_response_text": {"result": True},
106 },
107 ),
108 # Set timeout
109 (
110 "enigma2://user@localhost?timeout=-1000",
111 {
112 "instance": NotifyEnigma2,
113 "requests_response_text": {"result": True},
114 },
115 ),
116 # Set invalid timeout (defaults to a set value)
117 (
118 "enigma2://user@localhost?timeout=invalid",
119 {
120 "instance": NotifyEnigma2,
121 "requests_response_text": {"result": True},
122 },
123 ),
124 (
125 "enigma2://user:pass@localhost",
126 {
127 "instance": NotifyEnigma2,
128 "requests_response_text": {"result": True},
129 # Our expected url(privacy=True) startswith() response:
130 "privacy_url": "enigma2://user:****@localhost",
131 },
132 ),
133 (
134 "enigma2://localhost:8080",
135 {
136 "instance": NotifyEnigma2,
137 "requests_response_text": {"result": True},
138 },
139 ),
140 (
141 "enigma2://user:pass@localhost:8080",
142 {
143 "instance": NotifyEnigma2,
144 "requests_response_text": {"result": True},
145 },
146 ),
147 (
148 "enigma2s://localhost",
149 {
150 "instance": NotifyEnigma2,
151 "requests_response_text": {"result": True},
152 },
153 ),
154 (
155 "enigma2s://user:pass@localhost",
156 {
157 "instance": NotifyEnigma2,
158 "requests_response_text": {"result": True},
159 # Our expected url(privacy=True) startswith() response:
160 "privacy_url": "enigma2s://user:****@localhost",
161 },
162 ),
163 (
164 "enigma2s://localhost:8080/path/",
165 {
166 "instance": NotifyEnigma2,
167 "requests_response_text": {"result": True},
168 # Our expected url(privacy=True) startswith() response:
169 "privacy_url": "enigma2s://localhost:8080/path/",
170 },
171 ),
172 (
173 "enigma2s://user:pass@localhost:8080",
174 {
175 "instance": NotifyEnigma2,
176 "requests_response_text": {"result": True},
177 },
178 ),
179 (
180 "enigma2://localhost:8080/path?+HeaderKey=HeaderValue",
181 {
182 "instance": NotifyEnigma2,
183 "requests_response_text": {"result": True},
184 },
185 ),
186 (
187 "enigma2://user:pass@localhost:8081",
188 {
189 "instance": NotifyEnigma2,
190 "requests_response_text": {"result": True},
191 # force a failure
192 "response": False,
193 "requests_response_code": requests.codes.internal_server_error,
194 },
195 ),
196 (
197 "enigma2://user:pass@localhost:8082",
198 {
199 "instance": NotifyEnigma2,
200 "requests_response_text": {"result": True},
201 # throw a bizarre code forcing us to fail to look it up
202 "response": False,
203 "requests_response_code": 999,
204 },
205 ),
206 (
207 "enigma2://user:pass@localhost:8083",
208 {
209 "instance": NotifyEnigma2,
210 "requests_response_text": {"result": True},
211 # Throws a series of i/o exceptions with this flag
212 # is set and tests that we gracefully handle them
213 "test_requests_exceptions": True,
214 },
215 ),
216 )
217
218
219 def test_plugin_enigma2_urls():
220 """NotifyEnigma2() Apprise URLs."""
221
222 # Run our general tests
223 AppriseURLTester(tests=apprise_url_tests).run_all()