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
1=== modified file 'src/oopstools/oops/test/report.txt'
2--- src/oopstools/oops/test/report.txt 2011-10-13 20:18:51 +0000
3+++ src/oopstools/oops/test/report.txt 2012-08-07 04:00:26 +0000
4@@ -119,6 +119,7 @@
5 >>> from_addr
6 'OOPS Summaries <test@example.com>'
7
8+The global default email address was used.
9 >>> to_addr
10 'test@example.com'
11
12@@ -139,6 +140,11 @@
13
14 >>> helpers._today = date(2007, 11, 21)
15
16+At the same time, we want to set a custom report address.
17+
18+ >>> example_report.recipient = "demo@example.com"
19+ >>> example_report.save()
20+
21 Run the script again.
22
23 >>> report_mod.main()
24@@ -159,12 +165,12 @@
25 'OOPS Summaries <test@example.com>'
26
27 >>> to_addr
28- 'test@example.com'
29+ 'demo@example.com'
30
31 >>> message = message_from_string(msg)
32
33 >>> message.get('Reply-To')
34- 'test@example.com'
35+ 'demo@example.com'
36
37 >>> message.get('Subject')
38 'Example report Errors for 2007-11-20'
39
40=== modified file 'src/oopstools/scripts/report.py'
41--- src/oopstools/scripts/report.py 2012-07-27 04:27:53 +0000
42+++ src/oopstools/scripts/report.py 2012-08-07 04:00:26 +0000
43@@ -42,13 +42,14 @@
44 to_addr = report.recipient
45 if not to_addr:
46 to_addr = settings.REPORT_TO_ADDRESS
47+ if type(to_addr) is not str:
48+ to_addr = to_addr.encode('utf8')
49 msg['Reply-To'] = to_addr
50 msg['To'] = to_addr
51
52 # Send the email.
53 smtp_server.connect()
54- smtp_server.sendmail(
55- from_addr, settings.REPORT_TO_ADDRESS, msg.as_string())
56+ smtp_server.sendmail(from_addr, to_addr, msg.as_string())
57 smtp_server.quit()
58
59

Subscribers

People subscribed via source and target branches

to all changes: