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