예제 #1
0
    def test_email_overrides(self):
        p = ua.Push(None)
        p.audience = ua.all_
        p.notification = ua.notification(
            email=ua.email(
                message_type='transactional',
                plaintext_body='hello',
                reply_to='*****@*****.**',
                sender_address='*****@*****.**',
                sender_name='test_name',
                subject='hi',
                html_body='<html>so rich!</html>'
            )
        )
        p.device_types = ua.device_types('email')

        self.assertEqual(
            p.payload,
            {
                'audience': 'all',
                'device_types': ['email'],
                'notification': {
                    'email': {
                        'message_type': 'transactional',
                        'plaintext_body': 'hello',
                        'reply_to': '*****@*****.**',
                        'sender_address': '*****@*****.**',
                        'sender_name': 'test_name',
                        'subject': 'hi',
                        'html_body': '<html>so rich!</html>'
                    }
                }
            }
        )
예제 #2
0
    def test_email_overrides(self):
        p = ua.Push(None)
        p.audience = ua.all_
        p.notification = ua.notification(
            email=ua.email(message_type='transactional',
                           plaintext_body='hello',
                           reply_to='*****@*****.**',
                           sender_address='*****@*****.**',
                           sender_name='test_name',
                           subject='hi',
                           html_body='<html>so rich!</html>'))
        p.device_types = ua.device_types('email')

        self.assertEqual(
            p.payload, {
                'audience': 'all',
                'device_types': ['email'],
                'notification': {
                    'email': {
                        'message_type': 'transactional',
                        'plaintext_body': 'hello',
                        'reply_to': '*****@*****.**',
                        'sender_address': '*****@*****.**',
                        'sender_name': 'test_name',
                        'subject': 'hi',
                        'html_body': '<html>so rich!</html>'
                    }
                }
            })
 def test_email_send(self):
     cas = ua.CreateAndSendPush(
         airship=self.airship,
         channels=self.test_email_objs
     )
     cas.notification = ua.notification(
         email=ua.email(
             message_type='commercial',
             plaintext_body='this is an email',
             reply_to='*****@*****.**',
             sender_address='*****@*****.**',
             sender_name='test sender',
             subject='this is an email'
         )
     )
     cas.device_types = ua.device_types('email')
     cas.campaigns = ua.campaigns(
         categories=['email', 'fun']
     )
     self.assertEqual(
         cas.payload,
         {
             'audience': {
                 'create_and_send': [
                     {
                         'ua_address': '*****@*****.**',
                         'ua_commercial_opted_in': '2018-02-13T11:58:59'
                     },
                     {
                         'ua_address': '*****@*****.**',
                         'ua_commercial_opted_in': '2018-02-13T11:58:59'
                     },
                     {
                         'ua_address': '*****@*****.**',
                         'ua_commercial_opted_in': '2018-02-13T11:58:59'
                     }
                 ]
             },
             'device_types': ['email'],
             'notification': {
                 'email': {
                     'subject': 'this is an email',
                     'plaintext_body': 'this is an email',
                     'message_type': 'commercial',
                     'sender_name': 'test sender',
                     'sender_address': '*****@*****.**',
                     'reply_to': '*****@*****.**'
                 }
             },
             'campaigns': {
                 'categories': ['email', 'fun']
             }
         }
     )
예제 #4
0
    def test_email_with_device_type_all(self):
        p = ua.Push(None)
        p.audience = ua.all_
        p.notification = ua.notification(
            email=ua.email(message_type='transactional',
                           plaintext_body='hello',
                           reply_to='*****@*****.**',
                           sender_address='*****@*****.**',
                           sender_name='test_name',
                           subject='hi',
                           html_body='<html>so rich!</html>'))
        p.device_types = ua.all_

        with self.assertRaises(ValueError):
            p.send()
예제 #5
0
    def test_email_with_device_type_all(self):
        p = ua.Push(None)
        p.audience = ua.all_
        p.notification = ua.notification(
            email=ua.email(
                message_type='transactional',
                plaintext_body='hello',
                reply_to='*****@*****.**',
                sender_address='*****@*****.**',
                sender_name='test_name',
                subject='hi',
                html_body='<html>so rich!</html>'
            )
        )
        p.device_types = ua.all_

        with self.assertRaises(ValueError):
            p.send()
 def test_email_open_inline_template(self):
     cas = ua.CreateAndSendPush(
         airship=self.airship,
         channels=self.test_email_objs
     )
     cas.device_types = ua.device_types('email')
     cas.notification = ua.notification(
         email=ua.email(
             message_type='commercial',
             plaintext_body='{{name}} you are late for {{event}}',
             reply_to='*****@*****.**',
             sender_address='*****@*****.**',
             sender_name='test sender',
             subject='this is an email',
             variable_defaults=[
                 {
                     'key': 'name',
                     'default_value': 'hello'
                 },
                 {
                     'key': 'event',
                     'default_value': 'event'
                 }
             ]
         )
     )
     self.assertEqual(
         cas.payload,
         {
             'audience': {
                 'create_and_send': [
                     {
                         'ua_address': '*****@*****.**',
                         'ua_commercial_opted_in': '2018-02-13T11:58:59',
                         'name': 'bruce',
                         'event': 'zoom meeting'
                     },
                     {
                         'ua_address': '*****@*****.**',
                         'ua_commercial_opted_in': '2018-02-13T11:58:59',
                         'name': 'bruce',
                         'event': 'zoom meeting'
                     },
                     {
                         'ua_address': '*****@*****.**',
                         'ua_commercial_opted_in': '2018-02-13T11:58:59',
                         'name': 'bruce',
                         'event': 'zoom meeting'
                     }
                 ]
             },
             'device_types': ['email'],
             'notification': {
                 'email': {
                     'message_type': 'commercial',
                     'sender_name': 'test sender',
                     'sender_address': '*****@*****.**',
                     'reply_to': '*****@*****.**',
                     'template': {
                         'variable_defaults': [
                             {
                                 'key': 'name',
                                 'default_value': 'hello'
                             },
                             {
                                 'key': 'event',
                                 'default_value': 'event'
                             }
                         ],
                         'fields': {
                             'subject': 'this is an email',
                             'plaintext_body': '{{name}} you are late for {{event}}'
                         }
                     }
                 }
             }
         }
     )