| 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.ryver import NotifyRyver |
| 36 |
|
| 37 |
logging.disable(logging.CRITICAL) |
| 38 |
|
| 39 |
|
| 40 |
apprise_url_tests = ( |
| 41 |
( |
| 42 |
"ryver://", |
| 43 |
{ |
| 44 |
"instance": TypeError, |
| 45 |
}, |
| 46 |
), |
| 47 |
( |
| 48 |
"ryver://:@/", |
| 49 |
{ |
| 50 |
"instance": TypeError, |
| 51 |
}, |
| 52 |
), |
| 53 |
( |
| 54 |
"ryver://apprise", |
| 55 |
{ |
| 56 |
|
| 57 |
"instance": TypeError, |
| 58 |
}, |
| 59 |
), |
| 60 |
( |
| 61 |
"ryver://apprise/ckhrjW8w672m6HG?mode=invalid", |
| 62 |
{ |
| 63 |
|
| 64 |
"instance": TypeError, |
| 65 |
}, |
| 66 |
), |
| 67 |
( |
| 68 |
"ryver://x/ckhrjW8w672m6HG?mode=slack", |
| 69 |
{ |
| 70 |
|
| 71 |
"instance": TypeError, |
| 72 |
}, |
| 73 |
), |
| 74 |
( |
| 75 |
"ryver://apprise/ckhrjW8w672m6HG?mode=slack", |
| 76 |
{ |
| 77 |
|
| 78 |
|
| 79 |
"instance": NotifyRyver, |
| 80 |
}, |
| 81 |
), |
| 82 |
( |
| 83 |
"ryver://apprise/ckhrjW8w672m6HG?mode=ryver", |
| 84 |
{ |
| 85 |
|
| 86 |
|
| 87 |
"instance": NotifyRyver, |
| 88 |
}, |
| 89 |
), |
| 90 |
|
| 91 |
|
| 92 |
( |
| 93 |
"ryver://apprise/ckhrjW8w672m6HG?webhook=slack", |
| 94 |
{ |
| 95 |
|
| 96 |
|
| 97 |
"instance": NotifyRyver, |
| 98 |
}, |
| 99 |
), |
| 100 |
( |
| 101 |
"ryver://apprise/ckhrjW8w672m6HG?webhook=ryver", |
| 102 |
{ |
| 103 |
|
| 104 |
|
| 105 |
"instance": NotifyRyver, |
| 106 |
|
| 107 |
"privacy_url": "ryver://apprise/c...G", |
| 108 |
}, |
| 109 |
), |
| 110 |
|
| 111 |
( |
| 112 |
"https://apprise.ryver.com/application/webhook/ckhrjW8w672m6HG", |
| 113 |
{ |
| 114 |
"instance": NotifyRyver, |
| 115 |
}, |
| 116 |
), |
| 117 |
|
| 118 |
( |
| 119 |
( |
| 120 |
"https://apprise.ryver.com/application/webhook/ckhrjW8w672m6HG" |
| 121 |
"?webhook=ryver" |
| 122 |
), |
| 123 |
{ |
| 124 |
"instance": NotifyRyver, |
| 125 |
}, |
| 126 |
), |
| 127 |
( |
| 128 |
"ryver://caronc@apprise/ckhrjW8w672m6HG", |
| 129 |
{ |
| 130 |
"instance": NotifyRyver, |
| 131 |
|
| 132 |
"include_image": False, |
| 133 |
}, |
| 134 |
), |
| 135 |
( |
| 136 |
"ryver://apprise/ckhrjW8w672m6HG", |
| 137 |
{ |
| 138 |
"instance": NotifyRyver, |
| 139 |
|
| 140 |
"response": False, |
| 141 |
"requests_response_code": requests.codes.internal_server_error, |
| 142 |
}, |
| 143 |
), |
| 144 |
( |
| 145 |
"ryver://apprise/ckhrjW8w672m6HG", |
| 146 |
{ |
| 147 |
"instance": NotifyRyver, |
| 148 |
|
| 149 |
"response": False, |
| 150 |
"requests_response_code": 999, |
| 151 |
}, |
| 152 |
), |
| 153 |
( |
| 154 |
"ryver://apprise/ckhrjW8w672m6HG", |
| 155 |
{ |
| 156 |
"instance": NotifyRyver, |
| 157 |
|
| 158 |
|
| 159 |
"test_requests_exceptions": True, |
| 160 |
}, |
| 161 |
), |
| 162 |
) |
| 163 |
|
| 164 |
|
| 165 |
def test_plugin_ryver_urls(): |
| 166 |
"""NotifyRyver() Apprise URLs.""" |
| 167 |
|
| 168 |
|
| 169 |
AppriseURLTester(tests=apprise_url_tests).run_all() |
| 170 |
|
| 171 |
|
| 172 |
def test_plugin_ryver_edge_cases(): |
| 173 |
"""NotifyRyver() Edge Cases.""" |
| 174 |
|
| 175 |
|
| 176 |
with pytest.raises(TypeError): |
| 177 |
NotifyRyver(organization="abc", token=None) |
| 178 |
|
| 179 |
with pytest.raises(TypeError): |
| 180 |
NotifyRyver(organization="abc", token=" ") |
| 181 |
|
| 182 |
|
| 183 |
with pytest.raises(TypeError): |
| 184 |
NotifyRyver(organization=None, token="abc") |
| 185 |
|
| 186 |
with pytest.raises(TypeError): |
| 187 |
NotifyRyver(organization=" ", token="abc") |