Exemplo n.º 1
0
    def setUp(self):
        self.code = '0000-0000'
        self.auth = 'test_auth'

        self.client = client.PushwooshClient()
        self.command = CreateTargetedMessageCommand()
        self.command.auth = self.auth
        self.command.content = "Hello world!"
 def get_message(self):
     command = CreateTargetedMessageCommand()
     command.auth = PW_TOKEN
     command.content = "Hello world!"
     command.devices_filter = ApplicationFilter(PW_APP_CODE)
     tomorrow = datetime.datetime.today() + datetime.timedelta(1)
     command.send_date = tomorrow.strftime('%Y-%m-%d %H:%M:%S')
     response = self.client.invoke(command)
     return response['response']['messageCode']
 def get_message(self):
     command = CreateTargetedMessageCommand()
     command.auth = os.environ.get("PW_TOKEN")
     command.content = "Hello world!"
     command.devices_filter = ApplicationFilter(os.environ.get("PW_APP_CODE"))
     tomorrow = datetime.datetime.today() + datetime.timedelta(1)
     command.send_date = tomorrow.strftime("%Y-%m-%d %H:%M:%S")
     response = self.client.invoke(command)
     return response["response"]["messageCode"]
Exemplo n.º 4
0
def send_push_notification(receiver, message):
    command = CreateTargetedMessageCommand()
    command.auth = settings.PUSHWOOSH_AUTH_TOKEN
    command.devices_filter = ApplicationFilter(settings.PUSHWOOSH_APP_CODE)
    # TODO: I don't think this is actually limiting the devices sent to
    command.devices = [token.token for token in receiver.pushwoosh_tokens.all()]
    command.content = message

    client = PushwooshClient()
    return client.invoke(command)
class TestCreateTargetedMessageCommand(unittest.TestCase):

    def setUp(self):
        self.code = '0000-0000'
        self.auth = 'test_auth'

        self.client = client.PushwooshClient()
        self.command = CreateTargetedMessageCommand()
        self.command.auth = self.auth
        self.command.content = "Hello world!"

    def test_valid_create(self):
        expected_result = {
            'request': {
                'devices_filter': 'A("%s")' % self.code,
                'auth': self.auth,
                'content': 'Hello world!',
                'send_date': 'now'
            }
        }

        self.command.devices_filter = ApplicationFilter(self.code)

        command_dict = json.loads(self.command.render())
        self.assertDictEqual(command_dict, expected_result)

    def test_create_without_device_filter(self):
            self.assertRaises(PushwooshNotificationException, self.command.compile)
Exemplo n.º 6
0
class TestCreateTargetedMessageCommand(unittest.TestCase):

    def setUp(self):
        self.code = '0000-0000'
        self.auth = 'test_auth'

        self.client = client.PushwooshClient()
        self.command = CreateTargetedMessageCommand()
        self.command.auth = self.auth
        self.command.content = "Hello world!"

    def test_valid_create(self):
        expected_result = {
            'request': {
                'devices_filter': 'A("%s")' % self.code,
                'auth': self.auth,
                'content': 'Hello world!',
                'send_date': 'now'
            }
        }

        self.command.devices_filter = ApplicationFilter(self.code)

        command_dict = json.loads(self.command.render())
        self.assertDictEqual(command_dict, expected_result)

    def test_create_without_device_filter(self):
            self.assertRaises(PushwooshNotificationException, self.command.compile)
Exemplo n.º 7
0
    def setUp(self):
        super(TestCreateTargetedMessageCommand, self).setUp()

        self.client = client.PushwooshClient()
        self.command = CreateTargetedMessageCommand()
        self.command.auth = PW_TOKEN
        self.command.content = "Hello world!"
    def setUp(self):
        self.code = '0000-0000'
        self.auth = 'test_auth'

        self.client = client.PushwooshClient()
        self.command = CreateTargetedMessageCommand()
        self.command.auth = self.auth
        self.command.content = "Hello world!"
Exemplo n.º 9
0
 def get_message(self):
     command = CreateTargetedMessageCommand()
     command.auth = PW_TOKEN
     command.content = "Hello world!"
     command.devices_filter = ApplicationFilter(PW_APP_CODE)
     tomorrow = datetime.datetime.today() + datetime.timedelta(1)
     command.send_date = tomorrow.strftime('%Y-%m-%d %H:%M:%S')
     response = self.client.invoke(command)
     return response['response']['messageCode']