Debian Codegraph @

tests/test_plugin_notica.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.notica import NotifyNotica
35
36 logging.disable(logging.CRITICAL)
37
38 # Our Testing URLs
39 apprise_url_tests = (
40 (
41 "notica://",
42 {
43 "instance": TypeError,
44 },
45 ),
46 (
47 "notica://:@/",
48 {
49 "instance": TypeError,
50 },
51 ),
52 # Native URL
53 (
54 "https://notica.us/?%s" % ("z" * 6),
55 {
56 "instance": NotifyNotica,
57 # Our expected url(privacy=True) startswith() response:
58 "privacy_url": "notica://z...z/",
59 },
60 ),
61 # Native URL with additional arguments
62 (
63 "https://notica.us/?%s&overflow=upstream" % ("z" * 6),
64 {
65 "instance": NotifyNotica,
66 # Our expected url(privacy=True) startswith() response:
67 "privacy_url": "notica://z...z/",
68 },
69 ),
70 # Token specified
71 (
72 "notica://%s" % ("a" * 6),
73 {
74 "instance": NotifyNotica,
75 # Our expected url(privacy=True) startswith() response:
76 "privacy_url": "notica://a...a/",
77 },
78 ),
79 # Self-Hosted configuration
80 (
81 "notica://localhost/%s" % ("b" * 6),
82 {
83 "instance": NotifyNotica,
84 },
85 ),
86 (
87 "notica://user@localhost/%s" % ("c" * 6),
88 {
89 "instance": NotifyNotica,
90 },
91 ),
92 (
93 "notica://user:pass@localhost/%s/" % ("d" * 6),
94 {
95 "instance": NotifyNotica,
96 # Our expected url(privacy=True) startswith() response:
97 "privacy_url": "notica://user:****@localhost/d...d",
98 },
99 ),
100 (
101 "notica://user:pass@localhost/a/path/%s/" % ("r" * 6),
102 {
103 "instance": NotifyNotica,
104 # Our expected url(privacy=True) startswith() response:
105 "privacy_url": "notica://user:****@localhost/a/path/r...r",
106 },
107 ),
108 (
109 "notica://localhost:8080/%s" % ("a" * 6),
110 {
111 "instance": NotifyNotica,
112 },
113 ),
114 (
115 "notica://user:pass@localhost:8080/%s" % ("b" * 6),
116 {
117 "instance": NotifyNotica,
118 },
119 ),
120 (
121 "noticas://localhost/%s" % ("j" * 6),
122 {
123 "instance": NotifyNotica,
124 "privacy_url": "noticas://localhost/j...j",
125 },
126 ),
127 (
128 "noticas://user:pass@localhost/%s" % ("e" * 6),
129 {
130 "instance": NotifyNotica,
131 # Our expected url(privacy=True) startswith() response:
132 "privacy_url": "noticas://user:****@localhost/e...e",
133 },
134 ),
135 (
136 "noticas://localhost:8080/path/%s" % ("5" * 6),
137 {
138 "instance": NotifyNotica,
139 "privacy_url": "noticas://localhost:8080/path/5...5",
140 },
141 ),
142 (
143 "noticas://user:pass@localhost:8080/%s" % ("6" * 6),
144 {
145 "instance": NotifyNotica,
146 },
147 ),
148 (
149 "notica://%s" % ("b" * 6),
150 {
151 "instance": NotifyNotica,
152 # don't include an image by default
153 "include_image": False,
154 },
155 ),
156 # Test Header overrides
157 (
158 "notica://localhost:8080//%s/?+HeaderKey=HeaderValue" % ("7" * 6),
159 {
160 "instance": NotifyNotica,
161 },
162 ),
163 (
164 "notica://%s" % ("c" * 6),
165 {
166 "instance": NotifyNotica,
167 # force a failure
168 "response": False,
169 "requests_response_code": requests.codes.internal_server_error,
170 },
171 ),
172 (
173 "notica://%s" % ("d" * 7),
174 {
175 "instance": NotifyNotica,
176 # throw a bizarre code forcing us to fail to look it up
177 "response": False,
178 "requests_response_code": 999,
179 },
180 ),
181 (
182 "notica://%s" % ("e" * 8),
183 {
184 "instance": NotifyNotica,
185 # Throws a series of i/o exceptions with this flag
186 # is set and tests that we gracefully handle them
187 "test_requests_exceptions": True,
188 },
189 ),
190 )
191
192
193 def test_plugin_notica_urls():
194 """NotifyNotica() Apprise URLs."""
195
196 # Run our general tests
197 AppriseURLTester(tests=apprise_url_tests).run_all()