예제 #1
0
파일: test.py 프로젝트: laprice/pushover
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")
예제 #2
0
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")
예제 #3
0
    def setUp(self):
        self.APP_KEY = os.environ['PUSHOVER_APP_KEY']
        self.TEST_USER = os.environ['TEST_USER_KEY']
        if "PUSHOVER_MESSAGE" in os.environ:
            self.MESSAGE = os.environ["PUSHOVER_MESSAGE"]
        else:
            self.MESSAGE = "UNITESTING PUSHOVER CLIENT"

        assert (self.TEST_USER != "") and (self.APP_KEY != "")
        self.client = PushoverClient(self.APP_KEY)
예제 #4
0
파일: test.py 프로젝트: laprice/pushover
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
예제 #5
0
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:
        cls, instance, traceback = sys.exc_info()
        assert(instance.message=="The supplied message is bigger than 512 characters.")
    return
예제 #6
0
    def get_pushover_client(self):
        key = self.pushover_key

        if key is None:
            key = 'DUMMYKEY' # to return a valid client
        
        return PushoverClient(api_token=app.config.get('PUSHOVER_KEY'), user_key=key)
예제 #7
0
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
예제 #8
0
class TestPushoverClient(unittest.TestCase):
    def setUp(self):
        self.APP_KEY = os.environ['PUSHOVER_APP_KEY']
        self.TEST_USER = os.environ['TEST_USER_KEY']
        if "PUSHOVER_MESSAGE" in os.environ:
            self.MESSAGE = os.environ["PUSHOVER_MESSAGE"]
        else:
            self.MESSAGE = "UNITESTING PUSHOVER CLIENT"

        assert (self.TEST_USER != "") and (self.APP_KEY != "")
        self.client = PushoverClient(self.APP_KEY)

    def test_MessagePlain(self):
        assert (self.client.send_message(self.TEST_USER, self.MESSAGE) is True)

    def test_Message_With_Title(self):
        assert (self.client.send_message(self.TEST_USER, self.MESSAGE,
                                         "TEST TITLE") is True)

    def test_NOALERT_Message(self):
        assert (self.client.send_message(
            self.TEST_USER, self.MESSAGE, priority=PushoverPriority.NOALERT) is
                True)

    def test_QUIET_Message(self):
        assert (self.client.send_message(
            self.TEST_USER, self.MESSAGE, priority=PushoverPriority.QUIET) is
                True)

    def test_NORMAL_Message(self):
        assert (self.client.send_message(
            self.TEST_USER, self.MESSAGE, priority=PushoverPriority.NORMAL) is
                True)

    def test_HIGH_Message(self):
        assert (self.client.send_message(
            self.TEST_USER, self.MESSAGE, priority=PushoverPriority.HIGH) is
                True)

    def test_CONFIRM_NEEDED_Message(self):
        assert (self.client.send_message(
            self.TEST_USER,
            self.MESSAGE,
            priority=PushoverPriority.CONFIRM_NEEDED) is True)
예제 #9
0
    #print "Path:"
    #print path 
    #print "___________"

    #Connecing to the specified host 
    client = mosquitto.Mosquitto("echo reactor")

    user = "******"
    password = "******"

    if user != None:
        client.username_pw_set(user,password)

    client.connect(args.host)

    PushClient = PushoverClient(path + "/" + "pushover.cfg")
    PushClient.send_message(args.message)

    keyword = args.topic.find("/send")

    #We need to be in the send path to send confirmation message. Avoids loops.
    if keyword == -1:
	exit(0)


    topic = args.topic[:keyword]


    #Echoing the message recived. 
    client.publish(topic, "Message sent!", 1)
    client.disconnect()
예제 #10
0
   def execute(self, ad, name):
 
       po = PushoverClient("pushover.config")
       po.send_message("Hello, World : !"+name)
       
예제 #11
0
파일: co2.py 프로젝트: wickedchicken/co2
#!/usr/bin/env python2

import sys, fcntl, time, os

from Adafruit_IO import Client
from pushover import Client as PushoverClient

AIO_USER = os.getenv('AIO_USER')
AIO_KEY = os.getenv('AIO_USER')

PUSHOVER_CLIENT = os.getenv('PUSHOVER_CLIENT')
PUSHOVER_TOKEN = os.getenv('PUSHOVER_TOKEN')

aio = Client(AIO_USER, AIO_KEY)
pushover = PushoverClient(PUSHOVER_CLIENT, api_token=PUSHOVER_TOKEN)

def decrypt(key,  data):
    cstate = [0x48,  0x74,  0x65,  0x6D,  0x70,  0x39,  0x39,  0x65]
    shuffle = [2, 4, 0, 7, 1, 6, 5, 3]

    phase1 = [0] * 8
    for i, o in enumerate(shuffle):
        phase1[o] = data[i]

    phase2 = [0] * 8
    for i in range(8):
        phase2[i] = phase1[i] ^ key[i]

    phase3 = [0] * 8
    for i in range(8):
        phase3[i] = ( (phase2[i] >> 3) | (phase2[ (i-1+8)%8 ] << 5) ) & 0xff
예제 #12
0
파일: test.py 프로젝트: laprice/pushover
def test_send_message():
    ps = PushoverClient()
    ps.send_message("Test message from PushoverClient")
예제 #13
0
def test_send_message():
    ps = PushoverClient()
    ps.send_message("Test message from PushoverClient")