-
Notifications
You must be signed in to change notification settings - Fork 12
/
test.py
48 lines (38 loc) · 1.93 KB
/
test.py
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
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
from pushover import PushoverClient, PushoverException, PushoverMessageTooBig
import sys
def test_no_config():
try:
ps = PushoverClient(configfile="file_does_not_exist")
except PushoverException:
cls, instance, traceback = sys.exc_info()
assert(instance.message=="No valid configuration found")
return
def test_message_too_big():
try:
ps = PushoverClient()
ps.send_message("""
Whereas recognition of the inherent dignity and of the equal and inalienable rights of all members of the human family is the foundation of freedom, justice and peace in the world,
Whereas disregard and contempt for human rights have resulted in barbarous acts which have outraged the conscience of mankind, and the advent of a world in which human beings shall enjoy freedom of speech and belief and freedom from fear and want has been proclaimed as the highest aspiration of the common people,
Whereas it is essential, if man is not to be compelled to have recourse, as a last resort, to rebellion against tyranny and oppression, that human rights should be protected by the rule of law,
Whereas it is essential to promote the development of friendly relations between nations,""")
except PushoverMessageTooBig as instance:
assert(str(instance)=="The supplied message is bigger than 512 characters.")
return
def test_send_message():
ps = PushoverClient()
ps.send_message("Test message from PushoverClient")
def test_message_with_kwargs():
"""pushover.net updated their API to support a number of additional arguments
see https://pushover.net/api
"""
ps = PushoverClient()
ps.send_message("Fancy Test Message",
title="fancy test",
url="https://pushover.net/api",
priority="1")
if __name__=="__main__":
test_no_config()
test_message_too_big()
test_send_message()
test_message_with_kwargs()