Merge lp:~lifeless/python-oops-tools/fix-reports into lp:python-oops-tools

Proposed by Robert Collins
Status: Merged
Approved by: Robert Collins
Approved revision: 39
Merged at revision: 38
Proposed branch: lp:~lifeless/python-oops-tools/fix-reports
Merge into: lp:python-oops-tools
Diff against target: 57 lines (+11/-4)
2 files modified
src/oopstools/oops/test/report.txt (+8/-2)
src/oopstools/scripts/report.py (+3/-2)
To merge this branch: bzr merge lp:~lifeless/python-oops-tools/fix-reports
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+118469@code.launchpad.net

Commit message

Fix and test the per-report to address setting.

Description of the change

It was broken, this makes it work. With tests.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

Trivial

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/oopstools/oops/test/report.txt'
--- src/oopstools/oops/test/report.txt 2011-10-13 20:18:51 +0000
+++ src/oopstools/oops/test/report.txt 2012-08-07 04:00:26 +0000
@@ -119,6 +119,7 @@
119 >>> from_addr119 >>> from_addr
120 'OOPS Summaries <test@example.com>'120 'OOPS Summaries <test@example.com>'
121121
122The global default email address was used.
122 >>> to_addr123 >>> to_addr
123 'test@example.com'124 'test@example.com'
124125
@@ -139,6 +140,11 @@
139140
140 >>> helpers._today = date(2007, 11, 21)141 >>> helpers._today = date(2007, 11, 21)
141142
143At the same time, we want to set a custom report address.
144
145 >>> example_report.recipient = "demo@example.com"
146 >>> example_report.save()
147
142Run the script again.148Run the script again.
143149
144 >>> report_mod.main()150 >>> report_mod.main()
@@ -159,12 +165,12 @@
159 'OOPS Summaries <test@example.com>'165 'OOPS Summaries <test@example.com>'
160166
161 >>> to_addr167 >>> to_addr
162 'test@example.com'168 'demo@example.com'
163169
164 >>> message = message_from_string(msg)170 >>> message = message_from_string(msg)
165171
166 >>> message.get('Reply-To')172 >>> message.get('Reply-To')
167 'test@example.com'173 'demo@example.com'
168174
169 >>> message.get('Subject')175 >>> message.get('Subject')
170 'Example report Errors for 2007-11-20'176 'Example report Errors for 2007-11-20'
171177
=== modified file 'src/oopstools/scripts/report.py'
--- src/oopstools/scripts/report.py 2012-07-27 04:27:53 +0000
+++ src/oopstools/scripts/report.py 2012-08-07 04:00:26 +0000
@@ -42,13 +42,14 @@
42 to_addr = report.recipient42 to_addr = report.recipient
43 if not to_addr:43 if not to_addr:
44 to_addr = settings.REPORT_TO_ADDRESS44 to_addr = settings.REPORT_TO_ADDRESS
45 if type(to_addr) is not str:
46 to_addr = to_addr.encode('utf8')
45 msg['Reply-To'] = to_addr47 msg['Reply-To'] = to_addr
46 msg['To'] = to_addr48 msg['To'] = to_addr
4749
48 # Send the email.50 # Send the email.
49 smtp_server.connect()51 smtp_server.connect()
50 smtp_server.sendmail(52 smtp_server.sendmail(from_addr, to_addr, msg.as_string())
51 from_addr, settings.REPORT_TO_ADDRESS, msg.as_string())
52 smtp_server.quit()53 smtp_server.quit()
5354
5455

Subscribers

People subscribed via source and target branches

to all changes: