launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #10464
[Merge] lp:~stevenk/launchpad/refactor-bsf into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/refactor-bsf into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/refactor-bsf/+merge/117543
Refactor the BugSubscriptionFilter{Importance,Status,Tag} and their tests into two files rather than eight.
--
https://code.launchpad.net/~stevenk/launchpad/refactor-bsf/+merge/117543
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/refactor-bsf into lp:launchpad.
=== modified file 'lib/lp/bugs/model/bugsubscriptionfilter.py'
--- lib/lp/bugs/model/bugsubscriptionfilter.py 2012-03-13 00:45:33 +0000
+++ lib/lp/bugs/model/bugsubscriptionfilter.py 2012-07-31 23:11:27 +0000
@@ -1,12 +1,13 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
-# pylint: disable-msg=E0611,W0212
-
__metaclass__ = type
__all__ = [
'BugSubscriptionFilter',
+ 'BugSubscriptionFilterImportance',
'BugSubscriptionFilterMute',
+ 'BugSubscriptionFilterStatus',
+ 'BugSubscriptionFilterTag',
]
from itertools import chain
@@ -32,13 +33,6 @@
BugTaskImportance,
BugTaskStatus,
)
-from lp.bugs.model.bugsubscriptionfilterimportance import (
- BugSubscriptionFilterImportance,
- )
-from lp.bugs.model.bugsubscriptionfilterstatus import (
- BugSubscriptionFilterStatus,
- )
-from lp.bugs.model.bugsubscriptionfiltertag import BugSubscriptionFilterTag
from lp.registry.interfaces.person import validate_person
from lp.services import searchbuilder
from lp.services.database.constants import UTC_NOW
@@ -324,3 +318,49 @@
date_created = DateTime(
"date_created", allow_none=False, default=UTC_NOW,
tzinfo=pytz.UTC)
+
+
+class BugSubscriptionFilterStatus(StormBase):
+ """Statuses to filter."""
+
+ __storm_table__ = "BugSubscriptionFilterStatus"
+ __storm_primary__ = ('filter_id', 'status')
+
+ filter_id = Int("filter", allow_none=False)
+ filter = Reference(filter_id, "BugSubscriptionFilter.id")
+
+ status = DBEnum(enum=BugTaskStatus, allow_none=False)
+
+
+class BugSubscriptionFilterImportance(StormBase):
+ """Importances to filter."""
+
+ __storm_table__ = "BugSubscriptionFilterImportance"
+ __storm_primary__ = ('filter_id', 'importance')
+
+ filter_id = Int("filter", allow_none=False)
+ filter = Reference(filter_id, "BugSubscriptionFilter.id")
+
+ importance = DBEnum(enum=BugTaskImportance, allow_none=False)
+
+
+class BugSubscriptionFilterTag(StormBase):
+ """Tags to filter."""
+
+ __storm_table__ = "BugSubscriptionFilterTag"
+
+ id = Int(primary=True)
+
+ filter_id = Int("filter", allow_none=False)
+ filter = Reference(filter_id, "BugSubscriptionFilter.id")
+
+ include = Bool(allow_none=False)
+ tag = Unicode(allow_none=False)
+
+ @property
+ def qualified_tag(self):
+ """The tag qualified with a hyphen if it is to be omitted."""
+ if self.include:
+ return self.tag
+ else:
+ return u"-" + self.tag
=== removed file 'lib/lp/bugs/model/bugsubscriptionfilterimportance.py'
--- lib/lp/bugs/model/bugsubscriptionfilterimportance.py 2012-07-31 05:35:59 +0000
+++ lib/lp/bugs/model/bugsubscriptionfilterimportance.py 1970-01-01 00:00:00 +0000
@@ -1,28 +0,0 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-# pylint: disable-msg=E0611,W0212
-
-__metaclass__ = type
-__all__ = ['BugSubscriptionFilterImportance']
-
-from storm.locals import (
- Int,
- Reference,
- )
-
-from lp.bugs.interfaces.bugtask import BugTaskImportance
-from lp.services.database.enumcol import DBEnum
-from lp.services.database.stormbase import StormBase
-
-
-class BugSubscriptionFilterImportance(StormBase):
- """Importances to filter."""
-
- __storm_table__ = "BugSubscriptionFilterImportance"
- __storm_primary__ = ('filter_id', 'importance')
-
- filter_id = Int("filter", allow_none=False)
- filter = Reference(filter_id, "BugSubscriptionFilter.id")
-
- importance = DBEnum(enum=BugTaskImportance, allow_none=False)
=== removed file 'lib/lp/bugs/model/bugsubscriptionfilterstatus.py'
--- lib/lp/bugs/model/bugsubscriptionfilterstatus.py 2012-07-31 05:35:59 +0000
+++ lib/lp/bugs/model/bugsubscriptionfilterstatus.py 1970-01-01 00:00:00 +0000
@@ -1,28 +0,0 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-# pylint: disable-msg=E0611,W0212
-
-__metaclass__ = type
-__all__ = ['BugSubscriptionFilterStatus']
-
-from storm.locals import (
- Int,
- Reference,
- )
-
-from lp.bugs.interfaces.bugtask import BugTaskStatus
-from lp.services.database.enumcol import DBEnum
-from lp.services.database.stormbase import StormBase
-
-
-class BugSubscriptionFilterStatus(StormBase):
- """Statuses to filter."""
-
- __storm_table__ = "BugSubscriptionFilterStatus"
- __storm_primary__ = ('filter_id', 'status')
-
- filter_id = Int("filter", allow_none=False)
- filter = Reference(filter_id, "BugSubscriptionFilter.id")
-
- status = DBEnum(enum=BugTaskStatus, allow_none=False)
=== removed file 'lib/lp/bugs/model/bugsubscriptionfiltertag.py'
--- lib/lp/bugs/model/bugsubscriptionfiltertag.py 2011-01-24 20:10:41 +0000
+++ lib/lp/bugs/model/bugsubscriptionfiltertag.py 1970-01-01 00:00:00 +0000
@@ -1,38 +0,0 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-# pylint: disable-msg=E0611,W0212
-
-__metaclass__ = type
-__all__ = ['BugSubscriptionFilterTag']
-
-from storm.locals import (
- Bool,
- Int,
- Reference,
- Unicode,
- )
-
-from lp.services.database.stormbase import StormBase
-
-
-class BugSubscriptionFilterTag(StormBase):
- """Tags to filter."""
-
- __storm_table__ = "BugSubscriptionFilterTag"
-
- id = Int(primary=True)
-
- filter_id = Int("filter", allow_none=False)
- filter = Reference(filter_id, "BugSubscriptionFilter.id")
-
- include = Bool(allow_none=False)
- tag = Unicode(allow_none=False)
-
- @property
- def qualified_tag(self):
- """The tag qualified with a hyphen if it is to be omitted."""
- if self.include:
- return self.tag
- else:
- return u"-" + self.tag
=== modified file 'lib/lp/bugs/model/structuralsubscription.py'
--- lib/lp/bugs/model/structuralsubscription.py 2012-07-26 05:38:25 +0000
+++ lib/lp/bugs/model/structuralsubscription.py 2012-07-31 23:11:27 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -53,14 +53,12 @@
IStructuralSubscriptionTargetHelper,
)
from lp.bugs.model.bugsubscription import BugSubscription
-from lp.bugs.model.bugsubscriptionfilter import BugSubscriptionFilter
-from lp.bugs.model.bugsubscriptionfilterimportance import (
+from lp.bugs.model.bugsubscriptionfilter import (
+ BugSubscriptionFilter,
BugSubscriptionFilterImportance,
- )
-from lp.bugs.model.bugsubscriptionfilterstatus import (
BugSubscriptionFilterStatus,
+ BugSubscriptionFilterTag,
)
-from lp.bugs.model.bugsubscriptionfiltertag import BugSubscriptionFilterTag
from lp.registry.errors import (
DeleteSubscriptionError,
UserCannotSubscribePerson,
=== modified file 'lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py'
--- lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py 2012-03-13 00:45:33 +0000
+++ lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py 2012-07-31 23:11:27 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010-2011 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for the bugsubscription module."""
@@ -17,7 +17,12 @@
BugTaskImportance,
BugTaskStatus,
)
-from lp.bugs.model.bugsubscriptionfilter import BugSubscriptionFilter
+from lp.bugs.model.bugsubscriptionfilter import (
+ BugSubscriptionFilter,
+ BugSubscriptionFilterImportance,
+ BugSubscriptionFilterStatus,
+ BugSubscriptionFilterTag,
+ )
from lp.services import searchbuilder
from lp.services.database.lpstorm import IStore
from lp.testing import (
@@ -376,3 +381,114 @@
self.assertRaises(
Unauthorized, setattr, bug_subscription_filter,
"find_all_tags", True)
+
+
+class TestBugSubscriptionFilterImportance(TestCaseWithFactory):
+
+ layer = DatabaseFunctionalLayer
+
+ def setUp(self):
+ super(TestBugSubscriptionFilterImportance, self).setUp()
+ self.target = self.factory.makeProduct()
+ self.subscriber = self.target.owner
+ login_person(self.subscriber)
+ self.subscription = self.target.addBugSubscription(
+ self.subscriber, self.subscriber)
+ self.subscription_filter = BugSubscriptionFilter()
+ self.subscription_filter.structural_subscription = self.subscription
+
+ def test_basics(self):
+ """Test the basics of `BugSubscriptionFilterImportance` objects."""
+ # Create.
+ bug_sub_filter_importance = BugSubscriptionFilterImportance()
+ bug_sub_filter_importance.filter = self.subscription_filter
+ bug_sub_filter_importance.importance = BugTaskImportance.HIGH
+ # Flush and reload.
+ IStore(bug_sub_filter_importance).flush()
+ IStore(bug_sub_filter_importance).reload(bug_sub_filter_importance)
+ # Check.
+ self.assertEqual(
+ self.subscription_filter.id, bug_sub_filter_importance.filter_id)
+ self.assertEqual(
+ self.subscription_filter, bug_sub_filter_importance.filter)
+ self.assertEqual(
+ BugTaskImportance.HIGH, bug_sub_filter_importance.importance)
+
+
+class TestBugSubscriptionFilterStatus(TestCaseWithFactory):
+
+ layer = DatabaseFunctionalLayer
+
+ def setUp(self):
+ super(TestBugSubscriptionFilterStatus, self).setUp()
+ self.target = self.factory.makeProduct()
+ self.subscriber = self.target.owner
+ login_person(self.subscriber)
+ self.subscription = self.target.addBugSubscription(
+ self.subscriber, self.subscriber)
+ self.subscription_filter = BugSubscriptionFilter()
+ self.subscription_filter.structural_subscription = self.subscription
+
+ def test_basics(self):
+ """Test the basics of `BugSubscriptionFilterStatus` objects."""
+ # Create.
+ bug_sub_filter_status = BugSubscriptionFilterStatus()
+ bug_sub_filter_status.filter = self.subscription_filter
+ bug_sub_filter_status.status = BugTaskStatus.NEW
+ # Flush and reload.
+ IStore(bug_sub_filter_status).flush()
+ IStore(bug_sub_filter_status).reload(bug_sub_filter_status)
+ # Check.
+ self.assertEqual(
+ self.subscription_filter.id, bug_sub_filter_status.filter_id)
+ self.assertEqual(
+ self.subscription_filter, bug_sub_filter_status.filter)
+ self.assertEqual(BugTaskStatus.NEW, bug_sub_filter_status.status)
+
+
+class TestBugSubscriptionFilterTag(TestCaseWithFactory):
+
+ layer = DatabaseFunctionalLayer
+
+ def setUp(self):
+ super(TestBugSubscriptionFilterTag, self).setUp()
+ self.target = self.factory.makeProduct()
+ self.subscriber = self.target.owner
+ login_person(self.subscriber)
+ self.subscription = self.target.addBugSubscription(
+ self.subscriber, self.subscriber)
+ self.subscription_filter = BugSubscriptionFilter()
+ self.subscription_filter.structural_subscription = self.subscription
+
+ def test_basics(self):
+ """Test the basics of `BugSubscriptionFilterTag` objects."""
+ # Create.
+ bug_sub_filter_tag = BugSubscriptionFilterTag()
+ bug_sub_filter_tag.filter = self.subscription_filter
+ bug_sub_filter_tag.include = True
+ bug_sub_filter_tag.tag = u"foo"
+ # Flush and reload.
+ IStore(bug_sub_filter_tag).flush()
+ IStore(bug_sub_filter_tag).reload(bug_sub_filter_tag)
+ # Check.
+ self.assertIsNot(None, bug_sub_filter_tag.id)
+ self.assertEqual(
+ self.subscription_filter.id,
+ bug_sub_filter_tag.filter_id)
+ self.assertEqual(
+ self.subscription_filter,
+ bug_sub_filter_tag.filter)
+ self.assertIs(True, bug_sub_filter_tag.include)
+ self.assertEqual(u"foo", bug_sub_filter_tag.tag)
+
+ def test_qualified_tag(self):
+ """
+ `BugSubscriptionFilterTag.qualified_tag` returns a tag with a
+ preceding hyphen if `include` is `False`.
+ """
+ bug_sub_filter_tag = BugSubscriptionFilterTag()
+ bug_sub_filter_tag.tag = u"foo"
+ bug_sub_filter_tag.include = True
+ self.assertEqual(u"foo", bug_sub_filter_tag.qualified_tag)
+ bug_sub_filter_tag.include = False
+ self.assertEqual(u"-foo", bug_sub_filter_tag.qualified_tag)
=== removed file 'lib/lp/bugs/model/tests/test_bugsubscriptionfilterimportance.py'
--- lib/lp/bugs/model/tests/test_bugsubscriptionfilterimportance.py 2012-07-31 05:35:59 +0000
+++ lib/lp/bugs/model/tests/test_bugsubscriptionfilterimportance.py 1970-01-01 00:00:00 +0000
@@ -1,50 +0,0 @@
-# Copyright 2010 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Tests for the bugsubscription module."""
-
-__metaclass__ = type
-
-from lp.bugs.interfaces.bugtask import BugTaskImportance
-from lp.bugs.model.bugsubscriptionfilter import BugSubscriptionFilter
-from lp.bugs.model.bugsubscriptionfilterimportance import (
- BugSubscriptionFilterImportance,
- )
-from lp.services.database.lpstorm import IStore
-from lp.testing import (
- login_person,
- TestCaseWithFactory,
- )
-from lp.testing.layers import DatabaseFunctionalLayer
-
-
-class TestBugSubscriptionFilterImportance(TestCaseWithFactory):
-
- layer = DatabaseFunctionalLayer
-
- def setUp(self):
- super(TestBugSubscriptionFilterImportance, self).setUp()
- self.target = self.factory.makeProduct()
- self.subscriber = self.target.owner
- login_person(self.subscriber)
- self.subscription = self.target.addBugSubscription(
- self.subscriber, self.subscriber)
- self.subscription_filter = BugSubscriptionFilter()
- self.subscription_filter.structural_subscription = self.subscription
-
- def test_basics(self):
- """Test the basics of `BugSubscriptionFilterImportance` objects."""
- # Create.
- bug_sub_filter_importance = BugSubscriptionFilterImportance()
- bug_sub_filter_importance.filter = self.subscription_filter
- bug_sub_filter_importance.importance = BugTaskImportance.HIGH
- # Flush and reload.
- IStore(bug_sub_filter_importance).flush()
- IStore(bug_sub_filter_importance).reload(bug_sub_filter_importance)
- # Check.
- self.assertEqual(
- self.subscription_filter.id, bug_sub_filter_importance.filter_id)
- self.assertEqual(
- self.subscription_filter, bug_sub_filter_importance.filter)
- self.assertEqual(
- BugTaskImportance.HIGH, bug_sub_filter_importance.importance)
=== removed file 'lib/lp/bugs/model/tests/test_bugsubscriptionfilterstatus.py'
--- lib/lp/bugs/model/tests/test_bugsubscriptionfilterstatus.py 2012-07-31 05:35:59 +0000
+++ lib/lp/bugs/model/tests/test_bugsubscriptionfilterstatus.py 1970-01-01 00:00:00 +0000
@@ -1,49 +0,0 @@
-# Copyright 2010 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Tests for the bugsubscription module."""
-
-__metaclass__ = type
-
-from lp.bugs.interfaces.bugtask import BugTaskStatus
-from lp.bugs.model.bugsubscriptionfilter import BugSubscriptionFilter
-from lp.bugs.model.bugsubscriptionfilterstatus import (
- BugSubscriptionFilterStatus,
- )
-from lp.services.database.lpstorm import IStore
-from lp.testing import (
- login_person,
- TestCaseWithFactory,
- )
-from lp.testing.layers import DatabaseFunctionalLayer
-
-
-class TestBugSubscriptionFilterStatus(TestCaseWithFactory):
-
- layer = DatabaseFunctionalLayer
-
- def setUp(self):
- super(TestBugSubscriptionFilterStatus, self).setUp()
- self.target = self.factory.makeProduct()
- self.subscriber = self.target.owner
- login_person(self.subscriber)
- self.subscription = self.target.addBugSubscription(
- self.subscriber, self.subscriber)
- self.subscription_filter = BugSubscriptionFilter()
- self.subscription_filter.structural_subscription = self.subscription
-
- def test_basics(self):
- """Test the basics of `BugSubscriptionFilterStatus` objects."""
- # Create.
- bug_sub_filter_status = BugSubscriptionFilterStatus()
- bug_sub_filter_status.filter = self.subscription_filter
- bug_sub_filter_status.status = BugTaskStatus.NEW
- # Flush and reload.
- IStore(bug_sub_filter_status).flush()
- IStore(bug_sub_filter_status).reload(bug_sub_filter_status)
- # Check.
- self.assertEqual(
- self.subscription_filter.id, bug_sub_filter_status.filter_id)
- self.assertEqual(
- self.subscription_filter, bug_sub_filter_status.filter)
- self.assertEqual(BugTaskStatus.NEW, bug_sub_filter_status.status)
=== removed file 'lib/lp/bugs/model/tests/test_bugsubscriptionfiltertag.py'
--- lib/lp/bugs/model/tests/test_bugsubscriptionfiltertag.py 2012-01-06 11:08:30 +0000
+++ lib/lp/bugs/model/tests/test_bugsubscriptionfiltertag.py 1970-01-01 00:00:00 +0000
@@ -1,63 +0,0 @@
-# Copyright 2010 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Tests for the bugsubscription module."""
-
-__metaclass__ = type
-
-from lp.bugs.model.bugsubscriptionfilter import BugSubscriptionFilter
-from lp.bugs.model.bugsubscriptionfiltertag import BugSubscriptionFilterTag
-from lp.services.database.lpstorm import IStore
-from lp.testing import (
- login_person,
- TestCaseWithFactory,
- )
-from lp.testing.layers import DatabaseFunctionalLayer
-
-
-class TestBugSubscriptionFilterTag(TestCaseWithFactory):
-
- layer = DatabaseFunctionalLayer
-
- def setUp(self):
- super(TestBugSubscriptionFilterTag, self).setUp()
- self.target = self.factory.makeProduct()
- self.subscriber = self.target.owner
- login_person(self.subscriber)
- self.subscription = self.target.addBugSubscription(
- self.subscriber, self.subscriber)
- self.subscription_filter = BugSubscriptionFilter()
- self.subscription_filter.structural_subscription = self.subscription
-
- def test_basics(self):
- """Test the basics of `BugSubscriptionFilterTag` objects."""
- # Create.
- bug_sub_filter_tag = BugSubscriptionFilterTag()
- bug_sub_filter_tag.filter = self.subscription_filter
- bug_sub_filter_tag.include = True
- bug_sub_filter_tag.tag = u"foo"
- # Flush and reload.
- IStore(bug_sub_filter_tag).flush()
- IStore(bug_sub_filter_tag).reload(bug_sub_filter_tag)
- # Check.
- self.assertIsNot(None, bug_sub_filter_tag.id)
- self.assertEqual(
- self.subscription_filter.id,
- bug_sub_filter_tag.filter_id)
- self.assertEqual(
- self.subscription_filter,
- bug_sub_filter_tag.filter)
- self.assertIs(True, bug_sub_filter_tag.include)
- self.assertEqual(u"foo", bug_sub_filter_tag.tag)
-
- def test_qualified_tag(self):
- """
- `BugSubscriptionFilterTag.qualified_tag` returns a tag with a
- preceding hyphen if `include` is `False`.
- """
- bug_sub_filter_tag = BugSubscriptionFilterTag()
- bug_sub_filter_tag.tag = u"foo"
- bug_sub_filter_tag.include = True
- self.assertEqual(u"foo", bug_sub_filter_tag.qualified_tag)
- bug_sub_filter_tag.include = False
- self.assertEqual(u"-foo", bug_sub_filter_tag.qualified_tag)
Follow ups