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
=== modified file 'oops_datedir_repo/serializer_rfc822.py'
--- oops_datedir_repo/serializer_rfc822.py 2011-08-17 00:46:13 +0000
+++ oops_datedir_repo/serializer_rfc822.py 2011-08-25 18:28:52 +0000
@@ -78,7 +78,10 @@
78 topic = msg.getheader('page-id')78 topic = msg.getheader('page-id')
79 username = msg.getheader('user')79 username = msg.getheader('user')
80 url = msg.getheader('url')80 url = msg.getheader('url')
81 duration = int(float(msg.getheader('duration', '-1')))81 try:
82 duration = int(float(msg.getheader('duration', '-1')))
83 except ValueError:
84 duration = -1
82 informational = msg.getheader('informational')85 informational = msg.getheader('informational')
83 branch_nick = msg.getheader('branch')86 branch_nick = msg.getheader('branch')
84 revno = msg.getheader('revision')87 revno = msg.getheader('revision')
8588
=== modified file 'oops_datedir_repo/tests/test_serializer_rfc822.py'
--- oops_datedir_repo/tests/test_serializer_rfc822.py 2011-08-17 00:38:02 +0000
+++ oops_datedir_repo/tests/test_serializer_rfc822.py 2011-08-25 18:28:52 +0000
@@ -145,6 +145,16 @@
145 self.assertEqual(report['branch_nick'], 'mybranch')145 self.assertEqual(report['branch_nick'], 'mybranch')
146 self.assertEqual(report['revno'], '45')146 self.assertEqual(report['revno'], '45')
147147
148 def test_read_duration_as_string(self):
149 """Test ErrorReport.read()."""
150 fp = StringIO.StringIO(dedent("""\
151 Oops-Id: OOPS-A0001
152 Duration: foo/bar
153
154 """))
155 report = read(fp)
156 self.assertEqual(report['duration'], -1)
157
148 def test_read_reporter(self):158 def test_read_reporter(self):
149 """Test ErrorReport.read()."""159 """Test ErrorReport.read()."""
150 fp = StringIO.StringIO(dedent("""\160 fp = StringIO.StringIO(dedent("""\

Subscribers

People subscribed via source and target branches

to all changes: