Permalink
Browse files

Fixes bug 851511 - Caught another expected exception from suds in aut…

…omatic emails.
  • Loading branch information...
1 parent 57a1149 commit a27902944aa474f24799811698adaf297990bb11 @adngdb adngdb committed Mar 28, 2013
Showing with 17 additions and 2 deletions.
  1. +7 −0 socorro/cron/jobs/automatic_emails.py
  2. +10 −2 socorro/unittest/cron/jobs/test_automatic_emails.py
@@ -159,6 +159,13 @@ def send_email(self, report):
except exacttarget.NewsletterException:
# subscriber does not exist, let's give it an ID
subscriber_key = email
+ except Exception, error_msg:
+ # suds raises bare Python Exceptions, so we test if it's one that
+ # we expect and raise it if not
+ if 'Bad Request' in str(error_msg):
+ subscriber_key = email
+ else:
+ raise
fields = {
'EMAIL_ADDRESS_': email,
@@ -422,6 +422,11 @@ def test_error_in_send_email(self, exacttarget_mock):
'fake@example.com', 'error', exc_info=True
)
+ list_service = exacttarget_mock.return_value.list.return_value
+ list_service.get_subscriber.side_effect = (
+ Exception(404, 'Bad Request')
+ )
+
exacttarget_mock.return_value.trigger_send.side_effect = (
Exception(404, 'Bad Request')
)
@@ -440,7 +445,7 @@ def test_error_in_send_email(self, exacttarget_mock):
fields = {
'EMAIL_ADDRESS_': u'fake@example.com',
'EMAIL_FORMAT_': 'H',
- 'TOKEN': 'fake@example.com'
+ 'TOKEN': u'fake@example.com'
}
exacttarget_mock.return_value.trigger_send.assert_called_with(
'socorro_dev_test',
@@ -449,7 +454,10 @@ def test_error_in_send_email(self, exacttarget_mock):
self.assertEqual(config.logger.error.call_count, 2)
config.logger.error.assert_called_with(
'Unable to send an email to %s, fields are %s, error is: %s',
- u'fake@example.com', str(fields), "(404, 'Bad Request')", exc_info=True
+ u'fake@example.com',
+ str(fields),
+ "(404, 'Bad Request')",
+ exc_info=True
)
def test_update_user(self):

0 comments on commit a279029

Please sign in to comment.