Debian Codegraph @

tests/test_plugin_signl4.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.# BSD 2-Clause License
27
28 from json import dumps
29
30 # Disable logging for a cleaner testing output
31 import logging
32
33 from helpers import AppriseURLTester
34
35 from apprise.plugins.signl4 import (
36 NotifySIGNL4,
37 NotifyType,
38 )
39
40 logging.disable(logging.CRITICAL)
41
42 SIGNL4_GOOD_RESPONSE = dumps(
43 {
44 "eventId": "2516485120936941747_76d5cf30-27d2-4529-84ed-f31a8f2c72b1",
45 }
46 )
47
48 # Our Testing URLs
49 apprise_url_tests = (
50 (
51 "signl4://",
52 {
53 # We failed to identify any valid authentication
54 "instance": TypeError,
55 },
56 ),
57 (
58 "signl4://:@/",
59 {
60 # We failed to identify any valid authentication
61 "instance": TypeError,
62 },
63 ),
64 (
65 "signl4://%20%20/",
66 {
67 # invalid secret specified
68 "instance": TypeError,
69 },
70 ),
71 (
72 "signl4://secret/",
73 {
74 # No targets specified; this is allowed
75 "instance": NotifySIGNL4,
76 "notify_type": NotifyType.FAILURE,
77 # Our response expected server response
78 "requests_response_text": SIGNL4_GOOD_RESPONSE,
79 },
80 ),
81 (
82 "signl4://?secret=secret",
83 {
84 # No targets specified; this is allowed
85 "instance": NotifySIGNL4,
86 "notify_type": NotifyType.FAILURE,
87 # Our response expected server response
88 "requests_response_text": SIGNL4_GOOD_RESPONSE,
89 },
90 ),
91 (
92 "signl4://secret/?service=IoT",
93 {
94 # European Region
95 "instance": NotifySIGNL4,
96 "notify_type": NotifyType.FAILURE,
97 # Our response expected server response
98 "requests_response_text": SIGNL4_GOOD_RESPONSE,
99 },
100 ),
101 (
102 "signl4://secret/?filtering=yes",
103 {
104 # European Region
105 "instance": NotifySIGNL4,
106 "notify_type": NotifyType.FAILURE,
107 # Our response expected server response
108 "requests_response_text": SIGNL4_GOOD_RESPONSE,
109 },
110 ),
111 (
112 "signl4://secret/?location=40.6413111,-73.7781391",
113 {
114 # European Region
115 "instance": NotifySIGNL4,
116 "notify_type": NotifyType.FAILURE,
117 # Our response expected server response
118 "requests_response_text": SIGNL4_GOOD_RESPONSE,
119 },
120 ),
121 (
122 "signl4://secret/?alerting_scenario=singl4_ack",
123 {
124 # European Region
125 "instance": NotifySIGNL4,
126 "notify_type": NotifyType.FAILURE,
127 # Our response expected server response
128 "requests_response_text": SIGNL4_GOOD_RESPONSE,
129 },
130 ),
131 (
132 "signl4://secret/?filtering=False",
133 {
134 # European Region
135 "instance": NotifySIGNL4,
136 "notify_type": NotifyType.FAILURE,
137 # Our response expected server response
138 "requests_response_text": SIGNL4_GOOD_RESPONSE,
139 },
140 ),
141 (
142 "signl4://secret/?external_id=ar1234&status=new",
143 {
144 # European Region
145 "instance": NotifySIGNL4,
146 "notify_type": NotifyType.FAILURE,
147 # Our response expected server response
148 "requests_response_text": SIGNL4_GOOD_RESPONSE,
149 },
150 ),
151 (
152 "signl4://secret/",
153 {
154 "instance": NotifySIGNL4,
155 # throw a bizarre code forcing us to fail to look it up
156 "response": False,
157 "requests_response_code": 999,
158 },
159 ),
160 (
161 "signl4://secret/",
162 {
163 "instance": NotifySIGNL4,
164 # Throws a series of i/o exceptions with this flag
165 # is set and tests that we gracefully handle them
166 "test_requests_exceptions": True,
167 },
168 ),
169 )
170
171
172 def test_plugin_signl4_urls():
173 """NotifySIGNL4() Apprise URLs."""
174
175 # Run our general tests
176 AppriseURLTester(tests=apprise_url_tests).run_all()