Debian Codegraph @

tests/test_plugin_kumulos.py

raw
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 pytest
33 import requests
34
35 from apprise.exception import AppriseImproperlyConfigured
36 from apprise.plugins.kumulos import NotifyKumulos
37
38 logging.disable(logging.CRITICAL)
39
40 # a test UUID we can use
41 UUID4 = "8b799edf-6f98-4d3a-9be7-2862fb4e5752"
42
43 # Our Testing URLs
44 apprise_url_tests = (
45 (
46 "kumulos://",
47 {
48 # No API or Server Key specified
49 "instance": AppriseImproperlyConfigured,
50 },
51 ),
52 (
53 "kumulos://:@/",
54 {
55 # No API or Server Key specified
56 # We don't have strict host checking on for kumulos, so this URL
57 # actually becomes parseable and :@ becomes a hostname.
58 # The below errors because a second token wasn't found
59 "instance": AppriseImproperlyConfigured,
60 },
61 ),
62 (
63 f"kumulos://{UUID4}/",
64 {
65 # No server key was specified
66 "instance": AppriseImproperlyConfigured,
67 },
68 ),
69 (
70 "kumulos://{}/{}/".format(UUID4, "w" * 36),
71 {
72 # Everything is okay
73 "instance": NotifyKumulos,
74 # Our expected url(privacy=True) startswith() response:
75 "privacy_url": "kumulos://8...2/w...w/",
76 },
77 ),
78 (
79 "kumulos://{}/{}/".format(UUID4, "x" * 36),
80 {
81 "instance": NotifyKumulos,
82 # force a failure
83 "response": False,
84 "requests_response_code": requests.codes.internal_server_error,
85 # Our expected url(privacy=True) startswith() response:
86 "privacy_url": "kumulos://8...2/x...x/",
87 },
88 ),
89 (
90 "kumulos://{}/{}/".format(UUID4, "y" * 36),
91 {
92 "instance": NotifyKumulos,
93 # throw a bizarre code forcing us to fail to look it up
94 "response": False,
95 "requests_response_code": 999,
96 # Our expected url(privacy=True) startswith() response:
97 "privacy_url": "kumulos://8...2/y...y/",
98 },
99 ),
100 (
101 "kumulos://{}/{}/".format(UUID4, "z" * 36),
102 {
103 "instance": NotifyKumulos,
104 # Throws a series of i/o exceptions with this flag
105 # is set and tests that we gracefully handle them
106 "test_requests_exceptions": True,
107 },
108 ),
109 )
110
111
112 def test_plugin_kumulos_urls():
113 """NotifyKumulos() Apprise URLs."""
114
115 # Run our general tests
116 AppriseURLTester(tests=apprise_url_tests).run_all()
117
118
119 def test_plugin_kumulos_edge_cases():
120 """NotifyKumulos() Edge Cases."""
121
122 # Invalid API Key
123 with pytest.raises(AppriseImproperlyConfigured):
124 NotifyKumulos(None, None)
125 with pytest.raises(AppriseImproperlyConfigured):
126 NotifyKumulos(" ", None)
127
128 # Invalid Server Key
129 with pytest.raises(AppriseImproperlyConfigured):
130 NotifyKumulos("abcd", None)
131 with pytest.raises(AppriseImproperlyConfigured):
132 NotifyKumulos("abcd", " ")