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)
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', })
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', })
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])
def test_success(self): add_sms_user('foo', '8675309', False) self.send_sms.assert_called_with(['8675309'], 'bar')
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)
def test_success(self): add_sms_user('foo', '8675309', False) self.send_sms.assert_called_with(['8675309'], 'bar')
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)