Exemple #1
0
    def test_valid_create_by_application(self):
        self.command = CreateMessageForApplicationCommand(
            self.notification, application=PW_APP_CODE)
        self.command.auth = self.auth
        response = self.client.invoke(self.command)

        self.assertEqual(response['status_code'], HTTP_200_OK)
        self.assertEqual(response['status_message'], STATUS_OK)
        self.assertEqual(True, 'Messages' in response['response'])
    def test_valid_create_by_application(self):
        expected_result = {
            'request': {
                'application': self.code,
                'auth': self.auth,
                'notifications': [{
                    'content': 'Hello world!',
                    'send_date': 'now'
                }]
            }
        }
        self.command = CreateMessageForApplicationCommand(
            self.notification, application=self.code)
        self.command.auth = self.auth

        command_dict = json.loads(self.command.render())
        self.assertDictEqual(command_dict, expected_result)
Exemple #3
0
 def test_create_message_without_application(self):
     self.command = CreateMessageForApplicationCommand(self.notification)
     self.command.auth = self.auth
     self.assertRaises(PushwooshCommandException, self.command.compile)
from pypushwoosh.client import PushwooshClient
from pypushwoosh.command import CreateMessageForApplicationCommand
from pypushwoosh.notification import Notification

AUTH_TOKEN = 'AUTH_TOKEN'
APPLICATION_CODE = 'APP-CODE'

notification = Notification()
notification.content = 'Hello world!'
notification.devices = [
    'PUSH_TOKEN_0',
    'PUSH_TOKEN_1',
]

command = CreateMessageForApplicationCommand(notification, APPLICATION_CODE)
command.auth = AUTH_TOKEN

client = PushwooshClient()
response = client.invoke(command)