Merge lp:~abentley/launchpad/mark-dup-empty into lp:launchpad

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 13557
Proposed branch: lp:~abentley/launchpad/mark-dup-empty
Merge into: lp:launchpad
Diff against target: 42 lines (+13/-1)
2 files modified
lib/lp/bugs/model/bug.py (+2/-1)
lib/lp/bugs/model/tests/test_bug.py (+11/-0)
To merge this branch: bzr merge lp:~abentley/launchpad/mark-dup-empty
Reviewer Review Type Date Requested Status
j.c.sackett (community) Approve
Review via email: mp+69704@code.launchpad.net

Commit message

No AttributeError marking a bug as not a dupe.

Description of the change

= Summary =
Fix bug #811262: AttributeError: 'NoneType' object has no attribute 'updateHeat'

== Proposed fix ==
Do not assume that the current duplicate is non-None if markAsDuplicate is called with None.

== Pre-implementation notes ==
None

== Implementation details ==
The code assumed the bug must be a duplicate if markAsDuplicate(None) was called. I changed it to check for None.

== Tests ==
bin/test test_bug -t markAsD

== Demo and Q/A ==
Go to a bug's mark-as-duplicate page for a bug that is not alredy marked as a duplicate. Don't enter a value, and hit 'Change'. You should not get an oops.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/model/tests/test_bug.py
  lib/lp/bugs/model/bug.py

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

Good fix.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/bugs/model/bug.py'
--- lib/lp/bugs/model/bug.py 2011-07-22 00:28:34 +0000
+++ lib/lp/bugs/model/bug.py 2011-07-28 18:34:31 +0000
@@ -1863,7 +1863,8 @@
1863 # from having been a duplicate. We also update the bug that1863 # from having been a duplicate. We also update the bug that
1864 # was previously duplicated.1864 # was previously duplicated.
1865 self.updateHeat(affected_targets)1865 self.updateHeat(affected_targets)
1866 current_duplicateof.updateHeat(affected_targets)1866 if current_duplicateof is not None:
1867 current_duplicateof.updateHeat(affected_targets)
1867 return affected_targets1868 return affected_targets
18681869
1869 def markAsDuplicate(self, duplicate_of):1870 def markAsDuplicate(self, duplicate_of):
18701871
=== modified file 'lib/lp/bugs/model/tests/test_bug.py'
--- lib/lp/bugs/model/tests/test_bug.py 2011-07-22 00:28:34 +0000
+++ lib/lp/bugs/model/tests/test_bug.py 2011-07-28 18:34:31 +0000
@@ -3,6 +3,8 @@
33
4__metaclass__ = type4__metaclass__ = type
55
6from testtools.testcase import ExpectedException
7
6from canonical.testing.layers import DatabaseFunctionalLayer8from canonical.testing.layers import DatabaseFunctionalLayer
7from lp.bugs.enum import BugNotificationLevel9from lp.bugs.enum import BugNotificationLevel
8from lp.bugs.interfaces.bugtask import BugTaskStatus10from lp.bugs.interfaces.bugtask import BugTaskStatus
@@ -21,6 +23,15 @@
2123
22 layer = DatabaseFunctionalLayer24 layer = DatabaseFunctionalLayer
2325
26 def test_markAsDuplicate_None(self):
27 # Calling markAsDuplicate(None) on a bug that is not currently a
28 # duplicate works correctly, and does not raise an AttributeError.
29 bug = self.factory.makeBug()
30 with ExpectedException(AssertionError, 'AttributeError not raised'):
31 with ExpectedException(AttributeError, ''):
32 with person_logged_in(self.factory.makePerson()):
33 bug.markAsDuplicate(None)
34
24 def test_get_subscribers_for_person_unsubscribed(self):35 def test_get_subscribers_for_person_unsubscribed(self):
25 bug = self.factory.makeBug()36 bug = self.factory.makeBug()
26 person = self.factory.makePerson()37 person = self.factory.makePerson()