def test_interactive(self): p = ua.Push(None) p.audience = ua.all_ p.notification = ua.notification( alert='Hey, click yes!', interactive=ua.interactive( type='some_type', button_actions={ 'yes': { 'add_tag': 'clicked_yes', 'remove_tag': 'never_clicked_yes', 'open': { 'type': 'url', 'content': 'http://www.urbanairship.com' } }, 'no': { 'add_tag': 'hater' } })) 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': 'Hey, click yes!', 'interactive': { 'type': 'some_type', 'button_actions': { 'yes': { 'add_tag': 'clicked_yes', 'remove_tag': 'never_clicked_yes', 'open': { 'type': 'url', 'content': 'http://www.urbanairship.com' } }, 'no': { 'add_tag': 'hater' } } } }, 'device_types': 'all', 'message': { 'title': 'Title', 'body': 'Body', 'content_type': 'text/html', 'content_encoding': 'utf8', } })
def test_interactive_missing_button_actions(self): self.assertEqual( ua.interactive( type='a_type' ), { 'type': 'a_type' } )
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' } } )
def test_wearable(self): wearable = ua.wearable( background_image='http://example.com/background.png', extra_pages=[{ 'title': 'title', 'alert': 'wearable alert' }], interactive=ua.interactive( type='a_type', button_actions={'yes': { 'add_tag': 'clicked_yes' }})) self.assertEqual( ua.android(alert='android alert', local_only=False, wearable=wearable), { 'alert': 'android alert', 'local_only': False, 'wearable': { 'background_image': 'http://example.com/background.png', 'extra_pages': [{ 'title': 'title', 'alert': 'wearable alert' }], 'interactive': { 'type': 'a_type', 'button_actions': { 'yes': { 'add_tag': 'clicked_yes' } } } } })
def test_interactive(self): p = ua.Push(None) p.audience = ua.all_ p.notification = ua.notification( alert='Hey, click yes!', interactive=ua.interactive( type='some_type', button_actions={ 'yes': { 'add_tag': 'clicked_yes', 'remove_tag': 'never_clicked_yes', 'open': { 'type': 'url', 'content': 'http://www.urbanairship.com' } }, 'no': { 'add_tag': 'hater' } } ) ) 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': 'Hey, click yes!', 'interactive': { 'type': 'some_type', 'button_actions': { 'yes': { 'add_tag': 'clicked_yes', 'remove_tag': 'never_clicked_yes', 'open': { 'type': 'url', 'content': 'http://www.urbanairship.com' } }, 'no': { 'add_tag': 'hater' } } } }, 'device_types': 'all', 'message': { 'title': 'Title', 'body': 'Body', 'content_type': 'text/html', 'content_encoding': 'utf8', } } )
def test_interactive_missing_button_actions(self): self.assertEqual(ua.interactive(type='a_type'), {'type': 'a_type'})