testprog.py 586 Bytes
Newer Older
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 30 31 32 33 34 35
#!/usr/bin/env python3

"""Simple Create-Read-Delete test program"""

import json
import os
import pprint

from notifylib.api import Api

conffile = os.path.abspath('config.conf')
expected_template = 'simple.simple'
message_data = '{"message": "egg spam spam"}'

api = Api(conffile)

# Create
templates = api.get_templates()
print(templates)

opts = {
    'skel_id': expected_template,
    'data': json.loads(message_data),
}
nid = api.create(**opts)
print(nid)

# Read

n = api.get_rendered_notification(nid, 'simple', 'en')
pprint.pprint(n)

# Delete

api.call_action(nid, 'dismiss')