| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
import logging |
| 30 |
|
| 31 |
from helpers import AppriseURLTester |
| 32 |
import pytest |
| 33 |
import requests |
| 34 |
|
| 35 |
from apprise.plugins.zulip import NotifyZulip |
| 36 |
|
| 37 |
logging.disable(logging.CRITICAL) |
| 38 |
|
| 39 |
|
| 40 |
apprise_url_tests = ( |
| 41 |
( |
| 42 |
"zulip://", |
| 43 |
{ |
| 44 |
"instance": TypeError, |
| 45 |
}, |
| 46 |
), |
| 47 |
( |
| 48 |
"zulip://:@/", |
| 49 |
{ |
| 50 |
"instance": TypeError, |
| 51 |
}, |
| 52 |
), |
| 53 |
( |
| 54 |
"zulip://apprise", |
| 55 |
{ |
| 56 |
|
| 57 |
"instance": TypeError, |
| 58 |
}, |
| 59 |
), |
| 60 |
( |
| 61 |
"zulip://botname@apprise", |
| 62 |
{ |
| 63 |
|
| 64 |
"instance": TypeError, |
| 65 |
}, |
| 66 |
), |
| 67 |
|
| 68 |
( |
| 69 |
"zulip://botname@apprise/{}".format("a" * 24), |
| 70 |
{ |
| 71 |
"instance": TypeError, |
| 72 |
}, |
| 73 |
), |
| 74 |
|
| 75 |
( |
| 76 |
"zulip://....@apprise/{}".format("a" * 32), |
| 77 |
{ |
| 78 |
"instance": TypeError, |
| 79 |
}, |
| 80 |
), |
| 81 |
|
| 82 |
( |
| 83 |
"zulip://bot-name@apprise/{}".format("a" * 32), |
| 84 |
{ |
| 85 |
"instance": NotifyZulip, |
| 86 |
"privacy_url": "zulip://bot-name@apprise/a...a/", |
| 87 |
}, |
| 88 |
), |
| 89 |
|
| 90 |
( |
| 91 |
"zulip://botname@apprise/{}".format("a" * 32), |
| 92 |
{ |
| 93 |
"instance": NotifyZulip, |
| 94 |
|
| 95 |
"privacy_url": "zulip://botname@apprise/a...a/", |
| 96 |
}, |
| 97 |
), |
| 98 |
|
| 99 |
( |
| 100 |
"zulip://[email protected]/{}".format("a" * 32), |
| 101 |
{ |
| 102 |
"instance": NotifyZulip, |
| 103 |
}, |
| 104 |
), |
| 105 |
|
| 106 |
( |
| 107 |
"zulip://botname@apprise/{}/channel1/channel2".format("a" * 32), |
| 108 |
{ |
| 109 |
"instance": NotifyZulip, |
| 110 |
}, |
| 111 |
), |
| 112 |
|
| 113 |
( |
| 114 |
"zulip://botname@apprise/{}/?to=channel1/channel2".format("a" * 32), |
| 115 |
{ |
| 116 |
"instance": NotifyZulip, |
| 117 |
}, |
| 118 |
), |
| 119 |
|
| 120 |
( |
| 121 |
"zulip://botname@apprise/?token={}&to=channel1".format("a" * 32), |
| 122 |
{ |
| 123 |
"instance": NotifyZulip, |
| 124 |
}, |
| 125 |
), |
| 126 |
|
| 127 |
( |
| 128 |
"zulip://botname@apprise/{}/[email protected]/[email protected]".format( |
| 129 |
"a" * 32 |
| 130 |
), |
| 131 |
{ |
| 132 |
"instance": NotifyZulip, |
| 133 |
}, |
| 134 |
), |
| 135 |
( |
| 136 |
"zulip://botname@apprise/{}".format("a" * 32), |
| 137 |
{ |
| 138 |
"instance": NotifyZulip, |
| 139 |
|
| 140 |
"include_image": False, |
| 141 |
}, |
| 142 |
), |
| 143 |
( |
| 144 |
"zulip://botname@apprise/{}".format("a" * 32), |
| 145 |
{ |
| 146 |
"instance": NotifyZulip, |
| 147 |
|
| 148 |
"response": False, |
| 149 |
"requests_response_code": requests.codes.internal_server_error, |
| 150 |
}, |
| 151 |
), |
| 152 |
( |
| 153 |
"zulip://botname@apprise/{}".format("a" * 32), |
| 154 |
{ |
| 155 |
"instance": NotifyZulip, |
| 156 |
|
| 157 |
"response": False, |
| 158 |
"requests_response_code": 999, |
| 159 |
}, |
| 160 |
), |
| 161 |
( |
| 162 |
"zulip://botname@apprise/{}".format("a" * 32), |
| 163 |
{ |
| 164 |
"instance": NotifyZulip, |
| 165 |
|
| 166 |
|
| 167 |
"test_requests_exceptions": True, |
| 168 |
}, |
| 169 |
), |
| 170 |
) |
| 171 |
|
| 172 |
|
| 173 |
def test_plugin_zulip_urls(): |
| 174 |
"""NotifyZulip() Apprise URLs.""" |
| 175 |
|
| 176 |
|
| 177 |
AppriseURLTester(tests=apprise_url_tests).run_all() |
| 178 |
|
| 179 |
|
| 180 |
def test_plugin_zulip_edge_cases(): |
| 181 |
"""NotifyZulip() Edge Cases.""" |
| 182 |
|
| 183 |
|
| 184 |
token = "a" * 32 |
| 185 |
|
| 186 |
|
| 187 |
with pytest.raises(TypeError): |
| 188 |
NotifyZulip(botname="test", organization="#", token=token) |