예제 #1
0
    def test_actions(self):
        p = ua.Push(None)
        p.audience = ua.all_
        p.notification = ua.notification(
            alert='Hello',
            actions=ua.actions(
                add_tag='new_tag',
                remove_tag='old_tag',
                share='Check out Urban Airship!',
                open_={
                    'type': 'url',
                    'content': 'http://www.urbanairship.com'
                },
                app_defined={'some_app_defined_action': 'some_values'}
            )
        )
        p.device_types = ua.all_
        p.message = ua.message(
            title='Title',
            body='Body',
            content_type='text/html',
            content_encoding='utf8',
        )

        self.assertEqual(
            p.payload,
            {
                'audience': 'all',
                'notification': {
                    'alert': 'Hello',
                    'actions': {
                        'add_tag': 'new_tag',
                        'remove_tag': 'old_tag',
                        'share': 'Check out Urban Airship!',
                        'open': {
                            'type': 'url',
                            'content': 'http://www.urbanairship.com'
                        },
                        'app_defined': {
                            'some_app_defined_action': 'some_values'
                        }
                    }
                },
                'device_types': 'all',
                'message': {
                    'title': 'Title',
                    'body': 'Body',
                    'content_type': 'text/html',
                    'content_encoding': 'utf8',
                }
            }
        )
예제 #2
0
    def test_actions(self):
        p = ua.Push(None)
        p.audience = ua.all_
        p.notification = ua.notification(
            alert='Hello',
            actions=ua.actions(
                add_tag='new_tag',
                remove_tag='old_tag',
                share='Check out Urban Airship!',
                open_={
                    'type': 'url',
                    'content': 'http://www.urbanairship.com'
                },
                app_defined={'some_app_defined_action': 'some_values'}
            )
        )
        p.device_types = ua.all_
        p.message = ua.message(
            title='Title',
            body='Body',
            content_type='text/html',
            content_encoding='utf8',
        )

        self.assertEqual(
            p.payload,
            {
                'audience': 'all',
                'notification': {
                    'alert': 'Hello',
                    'actions': {
                        'add_tag': 'new_tag',
                        'remove_tag': 'old_tag',
                        'share': 'Check out Urban Airship!',
                        'open': {
                            'type': 'url',
                            'content': 'http://www.urbanairship.com'
                        },
                        'app_defined': {
                            'some_app_defined_action': 'some_values'
                        }
                    }
                },
                'device_types': 'all',
                'message': {
                    'title': 'Title',
                    'body': 'Body',
                    'content_type': 'text/html',
                    'content_encoding': 'utf8',
                }
            }
        )
예제 #3
0
    def test_in_app(self):
        self.maxDiff = None

        p = ua.Push(None)
        p.audience = ua.all_
        p.in_app = ua.in_app(
            alert='Alert message',
            display_type='banner',
            display={
                'position': 'top',
                'duration': '500'
            },
            interactive=ua.interactive(
                type='ua_yes_no_foreground',
                button_actions={
                    'yes': ua.actions(open_={
                        'type': 'url',
                        'content': 'https://www.urbanairship.com'
                    })
                }
            )
        )

        self.assertEqual(
            p.in_app,
            {
                'alert': 'Alert message',
                'display_type': 'banner',
                'display': {
                    'position': 'top',
                    'duration': '500'
                },
                'interactive': {
                    'button_actions': {
                        'yes': {
                            'open': {
                                'content': 'https://www.urbanairship.com',
                                'type': 'url'
                            }
                        }
                    },
                    'type': 'ua_yes_no_foreground'
                }
            }
        )
예제 #4
0
    def test_in_app(self):
        self.maxDiff = None

        p = ua.Push(None)
        p.audience = ua.all_
        p.in_app = ua.in_app(
            alert='Alert message',
            display_type='banner',
            display={
                'position': 'top',
                'duration': '500'
            },
            interactive=ua.interactive(
                type='ua_yes_no_foreground',
                button_actions={
                    'yes': ua.actions(open_={
                        'type': 'url',
                        'content': 'https://www.urbanairship.com'
                    })
                }
            )
        )

        self.assertEqual(
            p.in_app,
            {
                'alert': 'Alert message',
                'display_type': 'banner',
                'display': {
                    'position': 'top',
                    'duration': '500'
                },
                'interactive': {
                    'button_actions': {
                        'yes': {
                            'open': {
                                'content': 'https://www.urbanairship.com',
                                'type': 'url'
                            }
                        }
                    },
                    'type': 'ua_yes_no_foreground'
                }
            }
        )