def setUp(self):
        self.airship = ua.Airship(TEST_KEY, TEST_SECRET)
        self.test_sms_sender = '12345'
        self.test_sms_msisdns = ['15035556789', '15035556788', '15035556787']
        self.test_open_channel_addresses = [
            'bfecbb67-5352-4582-a95d-24e4760a3907',
            'bfecbb67-5352-4582-a95d-24e4760a3908',
            'bfecbb67-5352-4582-a95d-24e4760a3909'
        ]
        self.test_email_addresses = [
            '*****@*****.**',
            '*****@*****.**',
            '*****@*****.**'
        ]
        self.test_optin_datestring = '2018-02-13T11:58:59'
        self.template_fields = {
            'name': 'bruce',
            'event': 'zoom meeting'
        }
        self.test_sms_objs = []
        self.test_open_channel_objs = []
        self.test_email_objs = []
        self.template_alert = '{{name}} you are late for your {{event}}'

        for msisdn in self.test_sms_msisdns:
            sms_obj = ua.Sms(
                airship=self.airship,
                sender=self.test_sms_sender,
                opted_in=self.test_optin_datestring,
                msisdn=msisdn,
                template_fields=self.template_fields)
            self.test_sms_objs.append(sms_obj)
        for address in self.test_open_channel_addresses:
            open_channel_obj = ua.OpenChannel(
                airship=self.airship,
            )
            open_channel_obj.address = address
            open_channel_obj.open_platform = 'open::foo'
            open_channel_obj.template_fields = self.template_fields
            self.test_open_channel_objs.append(open_channel_obj)
        for email in self.test_email_addresses:
            email_obj = ua.Email(
                airship=self.airship,
                address=email,
                commercial_opted_in=self.test_optin_datestring,
                template_fields=self.template_fields
            )
            self.test_email_objs.append(email_obj)
    def test_mixed_platforms(self):
        email_channel = ua.Email(
            self.airship,
            address='*****@*****.**',
            commercial_opted_in=self.test_optin_datestring)
        mixed_channels = self.test_sms_objs
        mixed_channels.append(email_channel)

        cas = ua.CreateAndSendPush(
            self.airship,
            channels=mixed_channels
        )
        cas.device_types = ua.device_types('sms')
        cas.notification = ua.notification(alert='test sms')

        with self.assertRaises(TypeError):
            cas.payload
Exemplo n.º 3
0
    def test_email_update(self):
        with mock.patch.object(ua.Airship, '_request') as mock_request:
            response = requests.Response()
            response._content = json.dumps({
                'ok': True,
                'channel_id': self.channel_id
            }).encode('utf-8')
            response.status_code = 200
            mock_request.return_value = response

            email_obj = ua.Email(airship=self.airship,
                                 address=self.address)

            r = email_obj.register()

            self.assertEqual(self.channel_id, email_obj.channel_id)
            self.assertEqual(200, r.status_code)
Exemplo n.º 4
0
    def test_email_reg_w_opts(self):
        with mock.patch.object(ua.Airship, '_request') as mock_request:
            response = requests.Response()
            response._content = json.dumps({
                'ok': True,
                'channel_id': self.channel_id
            }).encode('utf-8')
            response.status_code = 201
            mock_request.return_value = response

            email_obj = ua.Email(airship=self.airship,
                                 address=self.address,
                                 locale_country=self.locale_country,
                                 locale_language=self.locale_language,
                                 timezone=self.timezone)

            r = email_obj.register()

            self.assertEqual(self.channel_id, email_obj.channel_id)
            self.assertEqual(201, r.status_code)
    def setUp(self):
        self.airship = ua.Airship(TEST_KEY, TEST_SECRET)
        self.test_sms_sender = '12345'
        self.test_sms_msisdns = ['15035556789', '15035556788', '15035556787']
        self.test_open_channel_addresses = [
            'bfecbb67-5352-4582-a95d-24e4760a3907',
            'bfecbb67-5352-4582-a95d-24e4760a3908',
            'bfecbb67-5352-4582-a95d-24e4760a3909'
        ]
        self.test_email_addresses = [
            '*****@*****.**',
            '*****@*****.**',
            '*****@*****.**'
        ]
        self.test_optin_datestring = '2018-02-13T11:58:59'
        self.test_sms_objs = []
        self.test_open_channel_objs = []
        self. test_email_objs = []

        for msisdn in self.test_sms_msisdns:
            sms_obj = ua.Sms(
                airship=self.airship,
                sender=self.test_sms_sender,
                opted_in=self.test_optin_datestring,
                msisdn=msisdn)
            self.test_sms_objs.append(sms_obj)
        for address in self.test_open_channel_addresses:
            open_channel_obj = ua.OpenChannel(
                airship=self.airship
            )
            open_channel_obj.address = address
            open_channel_obj.open_platform = 'open::foo'
            self.test_open_channel_objs.append(open_channel_obj)
        for email in self.test_email_addresses:
            email_obj = ua.Email(
                airship=self.airship,
                address=email,
                commercial_opted_in=self.test_optin_datestring
            )
            self.test_email_objs.append(email_obj)
Exemplo n.º 6
0
    def test_email_w_opt_dates(self):
        test_date = '2018-11-06T12:00:00Z'
        with mock.patch.object(ua.Airship, '_request') as mock_request:
            response = requests.Response()
            response._content = json.dumps({
                'ok': True,
                'channel_id': self.channel_id
            }).encode('utf-8')
            response.status_code = 201
            mock_request.return_value = response

            email_obj = ua.Email(airship=self.airship,
                                 address=self.address,
                                 commercial_opted_in=test_date,
                                 commercial_opted_out=test_date,
                                 transactional_opted_in=test_date,
                                 transactional_opted_out=test_date)

            r = email_obj.register()

            self.assertEqual(self.channel_id, email_obj.channel_id)
            self.assertEqual(201, r.status_code)