Merge lp:~bigkevmcd/offspring/fix-notification-emails into lp:offspring

Proposed by Kevin McDermott
Status: Merged
Merged at revision: 175
Proposed branch: lp:~bigkevmcd/offspring/fix-notification-emails
Merge into: lp:offspring
Diff against target: 36 lines (+17/-1)
2 files modified
lib/offspring/master/notifications.py (+4/-1)
lib/offspring/master/tests/test_notifications.py (+13/-0)
To merge this branch: bzr merge lp:~bigkevmcd/offspring/fix-notification-emails
Reviewer Review Type Date Requested Status
David Murphy (community) Approve
Review via email: mp+186282@code.launchpad.net

Description of the change

This catches errors parsing the build name, and allows the email to send, including the troublesome name in the subject.

To post a comment you must log in.
Revision history for this message
David Murphy (schwuk) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/offspring/master/notifications.py'
2--- lib/offspring/master/notifications.py 2013-03-05 11:32:52 +0000
3+++ lib/offspring/master/notifications.py 2013-09-18 09:59:48 +0000
4@@ -113,7 +113,10 @@
5 project = build_result.project
6 builder = build_result.builder
7
8- build_date, build_id = build_result.name.rsplit("-", 1)
9+ try:
10+ build_date, build_id = build_result.name.rsplit("-", 1)
11+ except ValueError:
12+ build_date, build_id = "ERROR", build_result.name
13 build_url = "%s/%s/%s/%s" % (
14 config.get("web", "build_results_uri"), project.name, build_date,
15 build_id)
16
17=== modified file 'lib/offspring/master/tests/test_notifications.py'
18--- lib/offspring/master/tests/test_notifications.py 2013-03-04 13:45:12 +0000
19+++ lib/offspring/master/tests/test_notifications.py 2013-09-18 09:59:48 +0000
20@@ -181,3 +181,16 @@
21 """
22 notify_buildresult(self.build_result, self.config, self.mailer.mail)
23 self.assertEqual([], self.mailer.mails)
24+
25+ def test_notify_buildresult_with_invalid_build_result_name(self):
26+ """
27+ Send an email users subscribed to a Project with details of the
28+ build result.
29+ """
30+ self.build_result.name = u"ERRORMESSAGE"
31+ self.subscribe_to_project(self.user, self.project)
32+ notify_buildresult(self.build_result, self.config, self.mailer.mail)
33+ self.assertEqual(self.user.email, self.mailer.mails[0][1])
34+ self.assertIn(
35+ "Subject: test-project (ERRORMESSAGE) build None",
36+ self.mailer.mails[0][2])

Subscribers

People subscribed via source and target branches