Merge lp:~matsubara/python-oops-datedir-repo/833912-duration-as-string into lp:python-oops-datedir-repo

Proposed by Diogo Matsubara
Status: Merged
Approved by: Robert Collins
Approved revision: 8
Merged at revision: 8
Proposed branch: lp:~matsubara/python-oops-datedir-repo/833912-duration-as-string
Merge into: lp:python-oops-datedir-repo
Diff against target: 36 lines (+14/-1)
2 files modified
oops_datedir_repo/serializer_rfc822.py (+4/-1)
oops_datedir_repo/tests/test_serializer_rfc822.py (+10/-0)
To merge this branch: bzr merge lp:~matsubara/python-oops-datedir-repo/833912-duration-as-string
Reviewer Review Type Date Requested Status
j.c.sackett (community) Approve
Review via email: mp+72936@code.launchpad.net

Description of the change

This branch fixes the case where an oops file has a duration header but the value is a non numerical string.

To post a comment you must log in.
Revision history for this message
j.c.sackett (jcsackett) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'oops_datedir_repo/serializer_rfc822.py'
2--- oops_datedir_repo/serializer_rfc822.py 2011-08-17 00:46:13 +0000
3+++ oops_datedir_repo/serializer_rfc822.py 2011-08-25 18:28:52 +0000
4@@ -78,7 +78,10 @@
5 topic = msg.getheader('page-id')
6 username = msg.getheader('user')
7 url = msg.getheader('url')
8- duration = int(float(msg.getheader('duration', '-1')))
9+ try:
10+ duration = int(float(msg.getheader('duration', '-1')))
11+ except ValueError:
12+ duration = -1
13 informational = msg.getheader('informational')
14 branch_nick = msg.getheader('branch')
15 revno = msg.getheader('revision')
16
17=== modified file 'oops_datedir_repo/tests/test_serializer_rfc822.py'
18--- oops_datedir_repo/tests/test_serializer_rfc822.py 2011-08-17 00:38:02 +0000
19+++ oops_datedir_repo/tests/test_serializer_rfc822.py 2011-08-25 18:28:52 +0000
20@@ -145,6 +145,16 @@
21 self.assertEqual(report['branch_nick'], 'mybranch')
22 self.assertEqual(report['revno'], '45')
23
24+ def test_read_duration_as_string(self):
25+ """Test ErrorReport.read()."""
26+ fp = StringIO.StringIO(dedent("""\
27+ Oops-Id: OOPS-A0001
28+ Duration: foo/bar
29+
30+ """))
31+ report = read(fp)
32+ self.assertEqual(report['duration'], -1)
33+
34 def test_read_reporter(self):
35 """Test ErrorReport.read()."""
36 fp = StringIO.StringIO(dedent("""\

Subscribers

People subscribed via source and target branches

to all changes: