| 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 |
import pickle |
| 31 |
import sys |
| 32 |
|
| 33 |
from apprise import Apprise, AppriseAsset, AppriseLocale |
| 34 |
|
| 35 |
logging.disable(logging.CRITICAL) |
| 36 |
|
| 37 |
|
| 38 |
sys.dont_write_bytecode = True |
| 39 |
|
| 40 |
|
| 41 |
def test_apprise_pickle_asset(tmpdir): |
| 42 |
"""pickle: AppriseAsset""" |
| 43 |
asset = AppriseAsset() |
| 44 |
serialized = pickle.dumps(asset) |
| 45 |
new_asset = pickle.loads(serialized) |
| 46 |
|
| 47 |
|
| 48 |
keys = ( |
| 49 |
"app_id", |
| 50 |
"app_desc", |
| 51 |
"app_url", |
| 52 |
"html_notify_map", |
| 53 |
"ascii_notify_map", |
| 54 |
"default_html_color", |
| 55 |
"default_extension", |
| 56 |
"theme", |
| 57 |
"image_url_mask", |
| 58 |
"image_url_logo", |
| 59 |
"image_path_mask", |
| 60 |
"body_format", |
| 61 |
"async_mode", |
| 62 |
"interpret_escapes", |
| 63 |
"encoding", |
| 64 |
"secure_logging", |
| 65 |
"_recursion", |
| 66 |
) |
| 67 |
|
| 68 |
for key in keys: |
| 69 |
assert getattr(asset, key) == getattr(new_asset, key) |
| 70 |
|
| 71 |
|
| 72 |
def test_apprise_pickle_locale(tmpdir): |
| 73 |
"""pickle: AppriseLocale""" |
| 74 |
locale = AppriseLocale() |
| 75 |
serialized = pickle.dumps(locale) |
| 76 |
new_locale = pickle.loads(serialized) |
| 77 |
|
| 78 |
assert locale.lang == new_locale.lang |
| 79 |
|
| 80 |
|
| 81 |
new_locale.detect_language() |
| 82 |
|
| 83 |
|
| 84 |
def test_apprise_pickle_core(tmpdir): |
| 85 |
"""pickle: Apprise""" |
| 86 |
asset = AppriseAsset(app_id="default") |
| 87 |
apobj = Apprise(asset=asset) |
| 88 |
|
| 89 |
|
| 90 |
xml_asset = AppriseAsset(app_id="xml") |
| 91 |
|
| 92 |
|
| 93 |
apobj.add("json://localhost") |
| 94 |
apobj.add("xml://localhost", asset=xml_asset) |
| 95 |
apobj.add("form://localhost") |
| 96 |
apobj.add("mailto://user:pass@localhost", tag="email") |
| 97 |
serialized = pickle.dumps(apobj) |
| 98 |
|
| 99 |
|
| 100 |
new_apobj = pickle.loads(serialized) |
| 101 |
|
| 102 |
|
| 103 |
assert len(new_apobj) == 4 |
| 104 |
|
| 105 |
|
| 106 |
assert apobj[0].app_id == "default" |
| 107 |
assert apobj[1].app_id == "xml" |
| 108 |
assert apobj[2].app_id == "default" |
| 109 |
assert apobj[3].app_id == "default" |
| 110 |
|
| 111 |
|
| 112 |
assert "email" in apobj[3].tags |