Debian Codegraph @

tests/test_plugin_streamlabs.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
33 from apprise.plugins.streamlabs import NotifyStreamlabs
34
35 logging.disable(logging.CRITICAL)
36
37 # Our Testing URLs
38 apprise_url_tests = (
39 (
40 "strmlabs://",
41 {
42 # No Access Token specified
43 "instance": TypeError,
44 },
45 ),
46 (
47 "strmlabs://a_bd_/",
48 {
49 # invalid Access Token
50 "instance": TypeError,
51 },
52 ),
53 (
54 "strmlabs://IcIcArukDQtuC1is1X1UdKZjTg118Lag2vScOmso",
55 {
56 # access token
57 "instance": NotifyStreamlabs,
58 # Our expected url(privacy=True) startswith() response:
59 "privacy_url": "strmlabs://I...o",
60 },
61 ),
62 # Test incorrect currency
63 (
64 "strmlabs://IcIcArukDQtuC1is1X1UdKZjTg118Lag2vScOmso/?currency=ABCD",
65 {
66 "instance": TypeError,
67 },
68 ),
69 # Test complete params - donations
70 (
71 (
72 "strmlabs://IcIcArukDQtuC1is1X1UdKZjTg118Lag2vScOmso/"
73 "?name=tt&identifier=pyt&amount=20&currency=USD&call=donations"
74 ),
75 {
76 "instance": NotifyStreamlabs,
77 },
78 ),
79 # Test complete params - donations
80 (
81 (
82 "strmlabs://IcIcArukDQtuC1is1X1UdKZjTg118Lag2vScOmso/"
83 "?image_href=https://example.org/rms.jpg"
84 "&sound_href=https://example.org/rms.mp3"
85 ),
86 {
87 "instance": NotifyStreamlabs,
88 },
89 ),
90 # Test complete params - alerts
91 (
92 (
93 "strmlabs://IcIcArukDQtuC1is1X1UdKZjTg118Lag2vScOmso/"
94 "?duration=1000&image_href=&"
95 "sound_href=&alert_type=donation&special_text_color=crimson"
96 ),
97 {
98 "instance": NotifyStreamlabs,
99 },
100 ),
101 # Test incorrect call
102 (
103 (
104 "strmlabs://IcIcArukDQtuC1is1X1UdKZjTg118Lag2vScOmso/"
105 "?name=tt&identifier=pyt&amount=20&currency=USD&call=rms"
106 ),
107 {
108 "instance": TypeError,
109 },
110 ),
111 # Test incorrect alert_type
112 (
113 (
114 "strmlabs://IcIcArukDQtuC1is1X1UdKZjTg118Lag2vScOmso/"
115 "?name=tt&identifier=pyt&amount=20&currency=USD&alert_type=rms"
116 ),
117 {
118 "instance": TypeError,
119 },
120 ),
121 # Test incorrect name
122 (
123 "strmlabs://IcIcArukDQtuC1is1X1UdKZjTg118Lag2vScOmso/?name=t",
124 {
125 "instance": TypeError,
126 },
127 ),
128 (
129 "strmlabs://IcIcArukDQtuC1is1X1UdKZjTg118Lag2vScOmso/?call=donations",
130 {
131 "instance": NotifyStreamlabs,
132 # A failure has status set to zero
133 # Test without an 'error' flag
134 "requests_response_text": {
135 "status": 0,
136 },
137 # throw a bizarre code forcing us to fail to look it up
138 "response": False,
139 "requests_response_code": 999,
140 },
141 ),
142 (
143 "strmlabs://IcIcArukDQtuC1is1X1UdKZjTg118Lag2vScOmso/?call=alerts",
144 {
145 "instance": NotifyStreamlabs,
146 # A failure has status set to zero
147 # Test without an 'error' flag
148 "requests_response_text": {
149 "status": 0,
150 },
151 # throw a bizarre code forcing us to fail to look it up
152 "response": False,
153 "requests_response_code": 999,
154 },
155 ),
156 (
157 "strmlabs://IcIcArukDQtuC1is1X1UdKZjTg118Lag2vScOmso/?call=alerts",
158 {
159 "instance": NotifyStreamlabs,
160 # Throws a series of i/o exceptions with this flag
161 # is set and tests that we gracefully handle them
162 "test_requests_exceptions": True,
163 },
164 ),
165 (
166 "strmlabs://IcIcArukDQtuC1is1X1UdKZjTg118Lag2vScOmso/?call=donations",
167 {
168 "instance": NotifyStreamlabs,
169 # Throws a series of i/o exceptions with this flag
170 # is set and tests that we gracefully handle them
171 "test_requests_exceptions": True,
172 },
173 ),
174 )
175
176
177 def test_plugin_streamlabs_urls():
178 """NotifyStreamlabs() Apprise URLs."""
179
180 # Run our general tests
181 AppriseURLTester(tests=apprise_url_tests).run_all()