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