Merge lp:~allenap/launchpad/bugtracker-snapshot-bug-447100 into lp:launchpad

Proposed by Gavin Panella
Status: Merged
Approved by: Данило Шеган
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~allenap/launchpad/bugtracker-snapshot-bug-447100
Merge into: lp:launchpad
Diff against target: 63 lines (+20/-6)
2 files modified
lib/lp/bugs/interfaces/bugtracker.py (+6/-4)
lib/lp/bugs/tests/test_bugtracker.py (+14/-2)
To merge this branch: bzr merge lp:~allenap/launchpad/bugtracker-snapshot-bug-447100
Reviewer Review Type Date Requested Status
Данило Шеган (community) release-critical Disapprove
Aaron Bentley (community) Approve
Review via email: mp+16130@code.launchpad.net

Commit message

Prevent IBugTracker.watches from being copied into snapshots.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Uses the doNotSnapshot() decorator to prevent the 'watches' property of IBugTracker being copied into a snapshot.

Revision history for this message
Aaron Bentley (abentley) wrote :

I think "self.failUnless(getattr(original, 'watches', marker) is not marker)" is a bit redundant, since there's no way for watches to have access to a freshly-created marker.

Could you explain the import reordering to me? it's just that it seems to go against PEP8's recommendation of '1. standard library imports, 2. related third party imports, 3. local application/library specific imports'

Revision history for this message
Aaron Bentley (abentley) wrote :

As discussed on IRC:
allenap: ...I think I should put lazr.lifecycle above the lp and canonical imports.
abentley: Approved, with that change

review: Approve
Revision history for this message
Данило Шеган (danilo) wrote :

As discussed on IRC, this affects only a very limited set of users (mostly Malone admins), so we'd be happy to have this on edge instead of going for an RC.

review: Disapprove (release-critical)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/bugs/interfaces/bugtracker.py'
--- lib/lp/bugs/interfaces/bugtracker.py 2009-10-02 11:29:22 +0000
+++ lib/lp/bugs/interfaces/bugtracker.py 2009-12-23 12:34:14 +0000
@@ -31,6 +31,7 @@
31from canonical.launchpad.validators import LaunchpadValidationError31from canonical.launchpad.validators import LaunchpadValidationError
32from canonical.launchpad.validators.name import name_validator32from canonical.launchpad.validators.name import name_validator
3333
34from lazr.lifecycle.snapshot import doNotSnapshot
34from lazr.restful.declarations import (35from lazr.restful.declarations import (
35 export_as_webservice_entry, exported)36 export_as_webservice_entry, exported)
36from lazr.restful.fields import CollectionField, Reference37from lazr.restful.fields import CollectionField, Reference
@@ -226,10 +227,11 @@
226 'security breach).'),227 'security breach).'),
227 required=False),228 required=False),
228 exported_as='contact_details')229 exported_as='contact_details')
229 watches = exported(230 watches = doNotSnapshot(
230 CollectionField(231 exported(
231 title=_('The remote watches on this bug tracker.'),232 CollectionField(
232 value_type=Reference(schema=IObject)))233 title=_('The remote watches on this bug tracker.'),
234 value_type=Reference(schema=IObject))))
233 has_lp_plugin = exported(235 has_lp_plugin = exported(
234 Bool(236 Bool(
235 title=_('This bug tracker has a Launchpad plugin installed.'),237 title=_('This bug tracker has a Launchpad plugin installed.'),
236238
=== modified file 'lib/lp/bugs/tests/test_bugtracker.py'
--- lib/lp/bugs/tests/test_bugtracker.py 2009-06-25 00:40:31 +0000
+++ lib/lp/bugs/tests/test_bugtracker.py 2009-12-23 12:34:14 +0000
@@ -8,10 +8,13 @@
8from zope.testing.doctest import NORMALIZE_WHITESPACE, ELLIPSIS8from zope.testing.doctest import NORMALIZE_WHITESPACE, ELLIPSIS
9from zope.testing.doctestunit import DocTestSuite9from zope.testing.doctestunit import DocTestSuite
1010
11from lazr.lifecycle.snapshot import Snapshot
12
11from canonical.launchpad.ftests import login, ANONYMOUS13from canonical.launchpad.ftests import login, ANONYMOUS
12from lp.bugs.interfaces.bugtracker import BugTrackerType14from canonical.testing import LaunchpadFunctionalLayer
15
16from lp.bugs.interfaces.bugtracker import BugTrackerType, IBugTracker
13from lp.testing import TestCaseWithFactory17from lp.testing import TestCaseWithFactory
14from canonical.testing import LaunchpadFunctionalLayer
1518
1619
17class TestBugTracker(TestCaseWithFactory):20class TestBugTracker(TestCaseWithFactory):
@@ -62,6 +65,15 @@
62 "no remote product is passed." %65 "no remote product is passed." %
63 type.title)66 type.title)
6467
68 def test_watches_not_in_snapshot(self):
69 # A snapshot of an IBugTracker will not contain a copy of the
70 # 'watches' property.
71 marker = object()
72 original = self.factory.makeBugTracker()
73 self.failUnless(getattr(original, 'watches', marker) is not marker)
74 snapshot = Snapshot(original, providing=IBugTracker)
75 self.failUnless(getattr(snapshot, 'watches', marker) is marker)
76
6577
66def test_suite():78def test_suite():
67 suite = unittest.TestSuite()79 suite = unittest.TestSuite()