Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug 851511 - Debug another error with automatic emails.

  • Loading branch information...
commit e2867957538b925385f9df690f2455d437caba57 1 parent 855c5c7
@AdrianGaudebert AdrianGaudebert authored
View
11 socorro/cron/jobs/automatic_emails.py
@@ -172,6 +172,17 @@ def send_email(self, report):
'Unable to send an email to %s, error is: %s',
email, str(error_msg), exc_info=True
)
+ 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):
+ logger.error(
+ 'Unable to send an email to %s, fields are %s, '
+ 'error is: %s',
+ email, str(fields), str(error_msg), exc_info=True
+ )
+ else:
+ raise
def update_user(self, report, sending_datetime, connection):
cursor = connection.cursor()
View
30 socorro/unittest/cron/jobs/test_automatic_emails.py
@@ -422,6 +422,36 @@ def test_error_in_send_email(self, exacttarget_mock):
'fake@example.com', 'error', exc_info=True
)
+ exacttarget_mock.return_value.trigger_send.side_effect = (
+ Exception(404, 'Bad Request')
+ )
+
+ with config_manager.context() as config:
+ job = automatic_emails.AutomaticEmailsCronApp(config, '')
+
+ report = {
+ 'email': 'fake@example.com',
+ 'product': 'WaterWolf',
+ 'version': '20.0',
+ 'release_channel': 'Release',
+ }
+ job.send_email(report)
+
+ fields = {
+ 'EMAIL_ADDRESS_': u'fake@example.com',
+ 'EMAIL_FORMAT_': 'H',
+ 'TOKEN': 'fake@example.com'
+ }
+ exacttarget_mock.return_value.trigger_send.assert_called_with(
+ 'socorro_dev_test',
+ fields
+ )
+ 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
+ )
+
def test_update_user(self):
config_manager = self._setup_simple_config()
with config_manager.context() as config:
Please sign in to comment.
Something went wrong with that request. Please try again.