Example #1
0
    def test_retry_on_error(self):
        """If an ETRestError is raised while sending an SMS, retry."""
        error = ETRestError()
        self.send_sms.side_effect = error

        with patch.object(add_sms_user, 'retry') as retry:
            add_sms_user('foo', '8675309', False)
            self.send_sms.assert_called_with(['8675309'], 'bar')
            retry.assert_called_with(exc=error)
Example #2
0
    def test_success_with_optin(self):
        """
        If optin is True, add a Mobile_Subscribers record for the
        number.
        """
        with patch('news.tasks.sfmc') as sfmc_mock:
            add_sms_user('foo', '8675309', True)

            sfmc_mock.add_row.assert_called_with('Mobile_Subscribers', {
                'Phone': '8675309',
                'SubscriberKey': '8675309',
            })
Example #3
0
    def test_success_with_optin(self):
        """
        If optin is True, add a Mobile_Subscribers record for the
        number.
        """
        with patch('news.tasks.sfmc') as sfmc_mock:
            add_sms_user('foo', '8675309', True)

            sfmc_mock.add_row.assert_called_with('Mobile_Subscribers', {
                'Phone': '8675309',
                'SubscriberKey': '8675309',
            })
Example #4
0
    def test_success_with_optin(self):
        """
        If optin is True, add a Mobile_Subscribers record for the
        number.
        """
        with patch('news.tasks.ExactTargetDataExt') as ExactTargetDataExt:
            with self.settings(EXACTTARGET_USER='******', EXACTTARGET_PASS='******'):
                add_sms_user('foo', '8675309', True)

            ExactTargetDataExt.assert_called_with('user', 'asdf')
            data_ext = ExactTargetDataExt.return_value
            call_args = data_ext.add_record.call_args

            self.assertEqual(call_args[0][0], 'Mobile_Subscribers')
            self.assertEqual(set(['Phone', 'SubscriberKey']), set(call_args[0][1]))
            self.assertEqual(['8675309', '8675309'], call_args[0][2])
Example #5
0
 def test_success(self):
     add_sms_user('foo', '8675309', False)
     self.send_sms.assert_called_with(['8675309'], 'bar')
Example #6
0
 def test_send_name_invalid(self):
     """If the send_name is invalid, return immediately."""
     add_sms_user('baffle', '8675309', False)
     self.assertFalse(self.send_sms.called)
Example #7
0
 def test_success(self):
     add_sms_user('foo', '8675309', False)
     self.send_sms.assert_called_with(['8675309'], 'bar')
Example #8
0
 def test_send_name_invalid(self):
     """If the send_name is invalid, return immediately."""
     add_sms_user('baffle', '8675309', False)
     self.assertFalse(self.send_sms.called)