Merge lp:~stevenk/launchpad/refactor-bsf into lp:launchpad
- refactor-bsf
- Merge into devel
Proposed by
Steve Kowalik
on 2012-07-31
| Status: | Merged |
|---|---|
| Approved by: | William Grant on 2012-07-31 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 15727 |
| Proposed branch: | lp:~stevenk/launchpad/refactor-bsf |
| Merge into: | lp:launchpad |
| Diff against target: |
537 lines (+172/-274) 9 files modified
lib/lp/bugs/model/bugsubscriptionfilter.py (+50/-10) lib/lp/bugs/model/bugsubscriptionfilterimportance.py (+0/-28) lib/lp/bugs/model/bugsubscriptionfilterstatus.py (+0/-28) lib/lp/bugs/model/bugsubscriptionfiltertag.py (+0/-38) lib/lp/bugs/model/structuralsubscription.py (+4/-6) lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py (+118/-2) lib/lp/bugs/model/tests/test_bugsubscriptionfilterimportance.py (+0/-50) lib/lp/bugs/model/tests/test_bugsubscriptionfilterstatus.py (+0/-49) lib/lp/bugs/model/tests/test_bugsubscriptionfiltertag.py (+0/-63) |
| To merge this branch: | bzr merge lp:~stevenk/launchpad/refactor-bsf |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| William Grant | code | 2012-07-31 | Approve on 2012-07-31 |
|
Review via email:
|
|||
Commit Message
Refactor the BugSubscription
Description of the Change
Refactor the BugSubscription
To post a comment you must log in.
review:
Approve
(code)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
| 1 | === modified file 'lib/lp/bugs/model/bugsubscriptionfilter.py' |
| 2 | --- lib/lp/bugs/model/bugsubscriptionfilter.py 2012-03-13 00:45:33 +0000 |
| 3 | +++ lib/lp/bugs/model/bugsubscriptionfilter.py 2012-07-31 23:11:27 +0000 |
| 4 | @@ -1,12 +1,13 @@ |
| 5 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
| 6 | +# Copyright 2009-2012 Canonical Ltd. This software is licensed under the |
| 7 | # GNU Affero General Public License version 3 (see the file LICENSE). |
| 8 | |
| 9 | -# pylint: disable-msg=E0611,W0212 |
| 10 | - |
| 11 | __metaclass__ = type |
| 12 | __all__ = [ |
| 13 | 'BugSubscriptionFilter', |
| 14 | + 'BugSubscriptionFilterImportance', |
| 15 | 'BugSubscriptionFilterMute', |
| 16 | + 'BugSubscriptionFilterStatus', |
| 17 | + 'BugSubscriptionFilterTag', |
| 18 | ] |
| 19 | |
| 20 | from itertools import chain |
| 21 | @@ -32,13 +33,6 @@ |
| 22 | BugTaskImportance, |
| 23 | BugTaskStatus, |
| 24 | ) |
| 25 | -from lp.bugs.model.bugsubscriptionfilterimportance import ( |
| 26 | - BugSubscriptionFilterImportance, |
| 27 | - ) |
| 28 | -from lp.bugs.model.bugsubscriptionfilterstatus import ( |
| 29 | - BugSubscriptionFilterStatus, |
| 30 | - ) |
| 31 | -from lp.bugs.model.bugsubscriptionfiltertag import BugSubscriptionFilterTag |
| 32 | from lp.registry.interfaces.person import validate_person |
| 33 | from lp.services import searchbuilder |
| 34 | from lp.services.database.constants import UTC_NOW |
| 35 | @@ -324,3 +318,49 @@ |
| 36 | date_created = DateTime( |
| 37 | "date_created", allow_none=False, default=UTC_NOW, |
| 38 | tzinfo=pytz.UTC) |
| 39 | + |
| 40 | + |
| 41 | +class BugSubscriptionFilterStatus(StormBase): |
| 42 | + """Statuses to filter.""" |
| 43 | + |
| 44 | + __storm_table__ = "BugSubscriptionFilterStatus" |
| 45 | + __storm_primary__ = ('filter_id', 'status') |
| 46 | + |
| 47 | + filter_id = Int("filter", allow_none=False) |
| 48 | + filter = Reference(filter_id, "BugSubscriptionFilter.id") |
| 49 | + |
| 50 | + status = DBEnum(enum=BugTaskStatus, allow_none=False) |
| 51 | + |
| 52 | + |
| 53 | +class BugSubscriptionFilterImportance(StormBase): |
| 54 | + """Importances to filter.""" |
| 55 | + |
| 56 | + __storm_table__ = "BugSubscriptionFilterImportance" |
| 57 | + __storm_primary__ = ('filter_id', 'importance') |
| 58 | + |
| 59 | + filter_id = Int("filter", allow_none=False) |
| 60 | + filter = Reference(filter_id, "BugSubscriptionFilter.id") |
| 61 | + |
| 62 | + importance = DBEnum(enum=BugTaskImportance, allow_none=False) |
| 63 | + |
| 64 | + |
| 65 | +class BugSubscriptionFilterTag(StormBase): |
| 66 | + """Tags to filter.""" |
| 67 | + |
| 68 | + __storm_table__ = "BugSubscriptionFilterTag" |
| 69 | + |
| 70 | + id = Int(primary=True) |
| 71 | + |
| 72 | + filter_id = Int("filter", allow_none=False) |
| 73 | + filter = Reference(filter_id, "BugSubscriptionFilter.id") |
| 74 | + |
| 75 | + include = Bool(allow_none=False) |
| 76 | + tag = Unicode(allow_none=False) |
| 77 | + |
| 78 | + @property |
| 79 | + def qualified_tag(self): |
| 80 | + """The tag qualified with a hyphen if it is to be omitted.""" |
| 81 | + if self.include: |
| 82 | + return self.tag |
| 83 | + else: |
| 84 | + return u"-" + self.tag |
| 85 | |
| 86 | === removed file 'lib/lp/bugs/model/bugsubscriptionfilterimportance.py' |
| 87 | --- lib/lp/bugs/model/bugsubscriptionfilterimportance.py 2012-07-31 05:35:59 +0000 |
| 88 | +++ lib/lp/bugs/model/bugsubscriptionfilterimportance.py 1970-01-01 00:00:00 +0000 |
| 89 | @@ -1,28 +0,0 @@ |
| 90 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
| 91 | -# GNU Affero General Public License version 3 (see the file LICENSE). |
| 92 | - |
| 93 | -# pylint: disable-msg=E0611,W0212 |
| 94 | - |
| 95 | -__metaclass__ = type |
| 96 | -__all__ = ['BugSubscriptionFilterImportance'] |
| 97 | - |
| 98 | -from storm.locals import ( |
| 99 | - Int, |
| 100 | - Reference, |
| 101 | - ) |
| 102 | - |
| 103 | -from lp.bugs.interfaces.bugtask import BugTaskImportance |
| 104 | -from lp.services.database.enumcol import DBEnum |
| 105 | -from lp.services.database.stormbase import StormBase |
| 106 | - |
| 107 | - |
| 108 | -class BugSubscriptionFilterImportance(StormBase): |
| 109 | - """Importances to filter.""" |
| 110 | - |
| 111 | - __storm_table__ = "BugSubscriptionFilterImportance" |
| 112 | - __storm_primary__ = ('filter_id', 'importance') |
| 113 | - |
| 114 | - filter_id = Int("filter", allow_none=False) |
| 115 | - filter = Reference(filter_id, "BugSubscriptionFilter.id") |
| 116 | - |
| 117 | - importance = DBEnum(enum=BugTaskImportance, allow_none=False) |
| 118 | |
| 119 | === removed file 'lib/lp/bugs/model/bugsubscriptionfilterstatus.py' |
| 120 | --- lib/lp/bugs/model/bugsubscriptionfilterstatus.py 2012-07-31 05:35:59 +0000 |
| 121 | +++ lib/lp/bugs/model/bugsubscriptionfilterstatus.py 1970-01-01 00:00:00 +0000 |
| 122 | @@ -1,28 +0,0 @@ |
| 123 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
| 124 | -# GNU Affero General Public License version 3 (see the file LICENSE). |
| 125 | - |
| 126 | -# pylint: disable-msg=E0611,W0212 |
| 127 | - |
| 128 | -__metaclass__ = type |
| 129 | -__all__ = ['BugSubscriptionFilterStatus'] |
| 130 | - |
| 131 | -from storm.locals import ( |
| 132 | - Int, |
| 133 | - Reference, |
| 134 | - ) |
| 135 | - |
| 136 | -from lp.bugs.interfaces.bugtask import BugTaskStatus |
| 137 | -from lp.services.database.enumcol import DBEnum |
| 138 | -from lp.services.database.stormbase import StormBase |
| 139 | - |
| 140 | - |
| 141 | -class BugSubscriptionFilterStatus(StormBase): |
| 142 | - """Statuses to filter.""" |
| 143 | - |
| 144 | - __storm_table__ = "BugSubscriptionFilterStatus" |
| 145 | - __storm_primary__ = ('filter_id', 'status') |
| 146 | - |
| 147 | - filter_id = Int("filter", allow_none=False) |
| 148 | - filter = Reference(filter_id, "BugSubscriptionFilter.id") |
| 149 | - |
| 150 | - status = DBEnum(enum=BugTaskStatus, allow_none=False) |
| 151 | |
| 152 | === removed file 'lib/lp/bugs/model/bugsubscriptionfiltertag.py' |
| 153 | --- lib/lp/bugs/model/bugsubscriptionfiltertag.py 2011-01-24 20:10:41 +0000 |
| 154 | +++ lib/lp/bugs/model/bugsubscriptionfiltertag.py 1970-01-01 00:00:00 +0000 |
| 155 | @@ -1,38 +0,0 @@ |
| 156 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
| 157 | -# GNU Affero General Public License version 3 (see the file LICENSE). |
| 158 | - |
| 159 | -# pylint: disable-msg=E0611,W0212 |
| 160 | - |
| 161 | -__metaclass__ = type |
| 162 | -__all__ = ['BugSubscriptionFilterTag'] |
| 163 | - |
| 164 | -from storm.locals import ( |
| 165 | - Bool, |
| 166 | - Int, |
| 167 | - Reference, |
| 168 | - Unicode, |
| 169 | - ) |
| 170 | - |
| 171 | -from lp.services.database.stormbase import StormBase |
| 172 | - |
| 173 | - |
| 174 | -class BugSubscriptionFilterTag(StormBase): |
| 175 | - """Tags to filter.""" |
| 176 | - |
| 177 | - __storm_table__ = "BugSubscriptionFilterTag" |
| 178 | - |
| 179 | - id = Int(primary=True) |
| 180 | - |
| 181 | - filter_id = Int("filter", allow_none=False) |
| 182 | - filter = Reference(filter_id, "BugSubscriptionFilter.id") |
| 183 | - |
| 184 | - include = Bool(allow_none=False) |
| 185 | - tag = Unicode(allow_none=False) |
| 186 | - |
| 187 | - @property |
| 188 | - def qualified_tag(self): |
| 189 | - """The tag qualified with a hyphen if it is to be omitted.""" |
| 190 | - if self.include: |
| 191 | - return self.tag |
| 192 | - else: |
| 193 | - return u"-" + self.tag |
| 194 | |
| 195 | === modified file 'lib/lp/bugs/model/structuralsubscription.py' |
| 196 | --- lib/lp/bugs/model/structuralsubscription.py 2012-07-26 05:38:25 +0000 |
| 197 | +++ lib/lp/bugs/model/structuralsubscription.py 2012-07-31 23:11:27 +0000 |
| 198 | @@ -1,4 +1,4 @@ |
| 199 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
| 200 | +# Copyright 2009-2012 Canonical Ltd. This software is licensed under the |
| 201 | # GNU Affero General Public License version 3 (see the file LICENSE). |
| 202 | |
| 203 | __metaclass__ = type |
| 204 | @@ -53,14 +53,12 @@ |
| 205 | IStructuralSubscriptionTargetHelper, |
| 206 | ) |
| 207 | from lp.bugs.model.bugsubscription import BugSubscription |
| 208 | -from lp.bugs.model.bugsubscriptionfilter import BugSubscriptionFilter |
| 209 | -from lp.bugs.model.bugsubscriptionfilterimportance import ( |
| 210 | +from lp.bugs.model.bugsubscriptionfilter import ( |
| 211 | + BugSubscriptionFilter, |
| 212 | BugSubscriptionFilterImportance, |
| 213 | - ) |
| 214 | -from lp.bugs.model.bugsubscriptionfilterstatus import ( |
| 215 | BugSubscriptionFilterStatus, |
| 216 | + BugSubscriptionFilterTag, |
| 217 | ) |
| 218 | -from lp.bugs.model.bugsubscriptionfiltertag import BugSubscriptionFilterTag |
| 219 | from lp.registry.errors import ( |
| 220 | DeleteSubscriptionError, |
| 221 | UserCannotSubscribePerson, |
| 222 | |
| 223 | === modified file 'lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py' |
| 224 | --- lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py 2012-03-13 00:45:33 +0000 |
| 225 | +++ lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py 2012-07-31 23:11:27 +0000 |
| 226 | @@ -1,4 +1,4 @@ |
| 227 | -# Copyright 2010-2011 Canonical Ltd. This software is licensed under the |
| 228 | +# Copyright 2010-2012 Canonical Ltd. This software is licensed under the |
| 229 | # GNU Affero General Public License version 3 (see the file LICENSE). |
| 230 | |
| 231 | """Tests for the bugsubscription module.""" |
| 232 | @@ -17,7 +17,12 @@ |
| 233 | BugTaskImportance, |
| 234 | BugTaskStatus, |
| 235 | ) |
| 236 | -from lp.bugs.model.bugsubscriptionfilter import BugSubscriptionFilter |
| 237 | +from lp.bugs.model.bugsubscriptionfilter import ( |
| 238 | + BugSubscriptionFilter, |
| 239 | + BugSubscriptionFilterImportance, |
| 240 | + BugSubscriptionFilterStatus, |
| 241 | + BugSubscriptionFilterTag, |
| 242 | + ) |
| 243 | from lp.services import searchbuilder |
| 244 | from lp.services.database.lpstorm import IStore |
| 245 | from lp.testing import ( |
| 246 | @@ -376,3 +381,114 @@ |
| 247 | self.assertRaises( |
| 248 | Unauthorized, setattr, bug_subscription_filter, |
| 249 | "find_all_tags", True) |
| 250 | + |
| 251 | + |
| 252 | +class TestBugSubscriptionFilterImportance(TestCaseWithFactory): |
| 253 | + |
| 254 | + layer = DatabaseFunctionalLayer |
| 255 | + |
| 256 | + def setUp(self): |
| 257 | + super(TestBugSubscriptionFilterImportance, self).setUp() |
| 258 | + self.target = self.factory.makeProduct() |
| 259 | + self.subscriber = self.target.owner |
| 260 | + login_person(self.subscriber) |
| 261 | + self.subscription = self.target.addBugSubscription( |
| 262 | + self.subscriber, self.subscriber) |
| 263 | + self.subscription_filter = BugSubscriptionFilter() |
| 264 | + self.subscription_filter.structural_subscription = self.subscription |
| 265 | + |
| 266 | + def test_basics(self): |
| 267 | + """Test the basics of `BugSubscriptionFilterImportance` objects.""" |
| 268 | + # Create. |
| 269 | + bug_sub_filter_importance = BugSubscriptionFilterImportance() |
| 270 | + bug_sub_filter_importance.filter = self.subscription_filter |
| 271 | + bug_sub_filter_importance.importance = BugTaskImportance.HIGH |
| 272 | + # Flush and reload. |
| 273 | + IStore(bug_sub_filter_importance).flush() |
| 274 | + IStore(bug_sub_filter_importance).reload(bug_sub_filter_importance) |
| 275 | + # Check. |
| 276 | + self.assertEqual( |
| 277 | + self.subscription_filter.id, bug_sub_filter_importance.filter_id) |
| 278 | + self.assertEqual( |
| 279 | + self.subscription_filter, bug_sub_filter_importance.filter) |
| 280 | + self.assertEqual( |
| 281 | + BugTaskImportance.HIGH, bug_sub_filter_importance.importance) |
| 282 | + |
| 283 | + |
| 284 | +class TestBugSubscriptionFilterStatus(TestCaseWithFactory): |
| 285 | + |
| 286 | + layer = DatabaseFunctionalLayer |
| 287 | + |
| 288 | + def setUp(self): |
| 289 | + super(TestBugSubscriptionFilterStatus, self).setUp() |
| 290 | + self.target = self.factory.makeProduct() |
| 291 | + self.subscriber = self.target.owner |
| 292 | + login_person(self.subscriber) |
| 293 | + self.subscription = self.target.addBugSubscription( |
| 294 | + self.subscriber, self.subscriber) |
| 295 | + self.subscription_filter = BugSubscriptionFilter() |
| 296 | + self.subscription_filter.structural_subscription = self.subscription |
| 297 | + |
| 298 | + def test_basics(self): |
| 299 | + """Test the basics of `BugSubscriptionFilterStatus` objects.""" |
| 300 | + # Create. |
| 301 | + bug_sub_filter_status = BugSubscriptionFilterStatus() |
| 302 | + bug_sub_filter_status.filter = self.subscription_filter |
| 303 | + bug_sub_filter_status.status = BugTaskStatus.NEW |
| 304 | + # Flush and reload. |
| 305 | + IStore(bug_sub_filter_status).flush() |
| 306 | + IStore(bug_sub_filter_status).reload(bug_sub_filter_status) |
| 307 | + # Check. |
| 308 | + self.assertEqual( |
| 309 | + self.subscription_filter.id, bug_sub_filter_status.filter_id) |
| 310 | + self.assertEqual( |
| 311 | + self.subscription_filter, bug_sub_filter_status.filter) |
| 312 | + self.assertEqual(BugTaskStatus.NEW, bug_sub_filter_status.status) |
| 313 | + |
| 314 | + |
| 315 | +class TestBugSubscriptionFilterTag(TestCaseWithFactory): |
| 316 | + |
| 317 | + layer = DatabaseFunctionalLayer |
| 318 | + |
| 319 | + def setUp(self): |
| 320 | + super(TestBugSubscriptionFilterTag, self).setUp() |
| 321 | + self.target = self.factory.makeProduct() |
| 322 | + self.subscriber = self.target.owner |
| 323 | + login_person(self.subscriber) |
| 324 | + self.subscription = self.target.addBugSubscription( |
| 325 | + self.subscriber, self.subscriber) |
| 326 | + self.subscription_filter = BugSubscriptionFilter() |
| 327 | + self.subscription_filter.structural_subscription = self.subscription |
| 328 | + |
| 329 | + def test_basics(self): |
| 330 | + """Test the basics of `BugSubscriptionFilterTag` objects.""" |
| 331 | + # Create. |
| 332 | + bug_sub_filter_tag = BugSubscriptionFilterTag() |
| 333 | + bug_sub_filter_tag.filter = self.subscription_filter |
| 334 | + bug_sub_filter_tag.include = True |
| 335 | + bug_sub_filter_tag.tag = u"foo" |
| 336 | + # Flush and reload. |
| 337 | + IStore(bug_sub_filter_tag).flush() |
| 338 | + IStore(bug_sub_filter_tag).reload(bug_sub_filter_tag) |
| 339 | + # Check. |
| 340 | + self.assertIsNot(None, bug_sub_filter_tag.id) |
| 341 | + self.assertEqual( |
| 342 | + self.subscription_filter.id, |
| 343 | + bug_sub_filter_tag.filter_id) |
| 344 | + self.assertEqual( |
| 345 | + self.subscription_filter, |
| 346 | + bug_sub_filter_tag.filter) |
| 347 | + self.assertIs(True, bug_sub_filter_tag.include) |
| 348 | + self.assertEqual(u"foo", bug_sub_filter_tag.tag) |
| 349 | + |
| 350 | + def test_qualified_tag(self): |
| 351 | + """ |
| 352 | + `BugSubscriptionFilterTag.qualified_tag` returns a tag with a |
| 353 | + preceding hyphen if `include` is `False`. |
| 354 | + """ |
| 355 | + bug_sub_filter_tag = BugSubscriptionFilterTag() |
| 356 | + bug_sub_filter_tag.tag = u"foo" |
| 357 | + bug_sub_filter_tag.include = True |
| 358 | + self.assertEqual(u"foo", bug_sub_filter_tag.qualified_tag) |
| 359 | + bug_sub_filter_tag.include = False |
| 360 | + self.assertEqual(u"-foo", bug_sub_filter_tag.qualified_tag) |
| 361 | |
| 362 | === removed file 'lib/lp/bugs/model/tests/test_bugsubscriptionfilterimportance.py' |
| 363 | --- lib/lp/bugs/model/tests/test_bugsubscriptionfilterimportance.py 2012-07-31 05:35:59 +0000 |
| 364 | +++ lib/lp/bugs/model/tests/test_bugsubscriptionfilterimportance.py 1970-01-01 00:00:00 +0000 |
| 365 | @@ -1,50 +0,0 @@ |
| 366 | -# Copyright 2010 Canonical Ltd. This software is licensed under the |
| 367 | -# GNU Affero General Public License version 3 (see the file LICENSE). |
| 368 | - |
| 369 | -"""Tests for the bugsubscription module.""" |
| 370 | - |
| 371 | -__metaclass__ = type |
| 372 | - |
| 373 | -from lp.bugs.interfaces.bugtask import BugTaskImportance |
| 374 | -from lp.bugs.model.bugsubscriptionfilter import BugSubscriptionFilter |
| 375 | -from lp.bugs.model.bugsubscriptionfilterimportance import ( |
| 376 | - BugSubscriptionFilterImportance, |
| 377 | - ) |
| 378 | -from lp.services.database.lpstorm import IStore |
| 379 | -from lp.testing import ( |
| 380 | - login_person, |
| 381 | - TestCaseWithFactory, |
| 382 | - ) |
| 383 | -from lp.testing.layers import DatabaseFunctionalLayer |
| 384 | - |
| 385 | - |
| 386 | -class TestBugSubscriptionFilterImportance(TestCaseWithFactory): |
| 387 | - |
| 388 | - layer = DatabaseFunctionalLayer |
| 389 | - |
| 390 | - def setUp(self): |
| 391 | - super(TestBugSubscriptionFilterImportance, self).setUp() |
| 392 | - self.target = self.factory.makeProduct() |
| 393 | - self.subscriber = self.target.owner |
| 394 | - login_person(self.subscriber) |
| 395 | - self.subscription = self.target.addBugSubscription( |
| 396 | - self.subscriber, self.subscriber) |
| 397 | - self.subscription_filter = BugSubscriptionFilter() |
| 398 | - self.subscription_filter.structural_subscription = self.subscription |
| 399 | - |
| 400 | - def test_basics(self): |
| 401 | - """Test the basics of `BugSubscriptionFilterImportance` objects.""" |
| 402 | - # Create. |
| 403 | - bug_sub_filter_importance = BugSubscriptionFilterImportance() |
| 404 | - bug_sub_filter_importance.filter = self.subscription_filter |
| 405 | - bug_sub_filter_importance.importance = BugTaskImportance.HIGH |
| 406 | - # Flush and reload. |
| 407 | - IStore(bug_sub_filter_importance).flush() |
| 408 | - IStore(bug_sub_filter_importance).reload(bug_sub_filter_importance) |
| 409 | - # Check. |
| 410 | - self.assertEqual( |
| 411 | - self.subscription_filter.id, bug_sub_filter_importance.filter_id) |
| 412 | - self.assertEqual( |
| 413 | - self.subscription_filter, bug_sub_filter_importance.filter) |
| 414 | - self.assertEqual( |
| 415 | - BugTaskImportance.HIGH, bug_sub_filter_importance.importance) |
| 416 | |
| 417 | === removed file 'lib/lp/bugs/model/tests/test_bugsubscriptionfilterstatus.py' |
| 418 | --- lib/lp/bugs/model/tests/test_bugsubscriptionfilterstatus.py 2012-07-31 05:35:59 +0000 |
| 419 | +++ lib/lp/bugs/model/tests/test_bugsubscriptionfilterstatus.py 1970-01-01 00:00:00 +0000 |
| 420 | @@ -1,49 +0,0 @@ |
| 421 | -# Copyright 2010 Canonical Ltd. This software is licensed under the |
| 422 | -# GNU Affero General Public License version 3 (see the file LICENSE). |
| 423 | - |
| 424 | -"""Tests for the bugsubscription module.""" |
| 425 | - |
| 426 | -__metaclass__ = type |
| 427 | - |
| 428 | -from lp.bugs.interfaces.bugtask import BugTaskStatus |
| 429 | -from lp.bugs.model.bugsubscriptionfilter import BugSubscriptionFilter |
| 430 | -from lp.bugs.model.bugsubscriptionfilterstatus import ( |
| 431 | - BugSubscriptionFilterStatus, |
| 432 | - ) |
| 433 | -from lp.services.database.lpstorm import IStore |
| 434 | -from lp.testing import ( |
| 435 | - login_person, |
| 436 | - TestCaseWithFactory, |
| 437 | - ) |
| 438 | -from lp.testing.layers import DatabaseFunctionalLayer |
| 439 | - |
| 440 | - |
| 441 | -class TestBugSubscriptionFilterStatus(TestCaseWithFactory): |
| 442 | - |
| 443 | - layer = DatabaseFunctionalLayer |
| 444 | - |
| 445 | - def setUp(self): |
| 446 | - super(TestBugSubscriptionFilterStatus, self).setUp() |
| 447 | - self.target = self.factory.makeProduct() |
| 448 | - self.subscriber = self.target.owner |
| 449 | - login_person(self.subscriber) |
| 450 | - self.subscription = self.target.addBugSubscription( |
| 451 | - self.subscriber, self.subscriber) |
| 452 | - self.subscription_filter = BugSubscriptionFilter() |
| 453 | - self.subscription_filter.structural_subscription = self.subscription |
| 454 | - |
| 455 | - def test_basics(self): |
| 456 | - """Test the basics of `BugSubscriptionFilterStatus` objects.""" |
| 457 | - # Create. |
| 458 | - bug_sub_filter_status = BugSubscriptionFilterStatus() |
| 459 | - bug_sub_filter_status.filter = self.subscription_filter |
| 460 | - bug_sub_filter_status.status = BugTaskStatus.NEW |
| 461 | - # Flush and reload. |
| 462 | - IStore(bug_sub_filter_status).flush() |
| 463 | - IStore(bug_sub_filter_status).reload(bug_sub_filter_status) |
| 464 | - # Check. |
| 465 | - self.assertEqual( |
| 466 | - self.subscription_filter.id, bug_sub_filter_status.filter_id) |
| 467 | - self.assertEqual( |
| 468 | - self.subscription_filter, bug_sub_filter_status.filter) |
| 469 | - self.assertEqual(BugTaskStatus.NEW, bug_sub_filter_status.status) |
| 470 | |
| 471 | === removed file 'lib/lp/bugs/model/tests/test_bugsubscriptionfiltertag.py' |
| 472 | --- lib/lp/bugs/model/tests/test_bugsubscriptionfiltertag.py 2012-01-06 11:08:30 +0000 |
| 473 | +++ lib/lp/bugs/model/tests/test_bugsubscriptionfiltertag.py 1970-01-01 00:00:00 +0000 |
| 474 | @@ -1,63 +0,0 @@ |
| 475 | -# Copyright 2010 Canonical Ltd. This software is licensed under the |
| 476 | -# GNU Affero General Public License version 3 (see the file LICENSE). |
| 477 | - |
| 478 | -"""Tests for the bugsubscription module.""" |
| 479 | - |
| 480 | -__metaclass__ = type |
| 481 | - |
| 482 | -from lp.bugs.model.bugsubscriptionfilter import BugSubscriptionFilter |
| 483 | -from lp.bugs.model.bugsubscriptionfiltertag import BugSubscriptionFilterTag |
| 484 | -from lp.services.database.lpstorm import IStore |
| 485 | -from lp.testing import ( |
| 486 | - login_person, |
| 487 | - TestCaseWithFactory, |
| 488 | - ) |
| 489 | -from lp.testing.layers import DatabaseFunctionalLayer |
| 490 | - |
| 491 | - |
| 492 | -class TestBugSubscriptionFilterTag(TestCaseWithFactory): |
| 493 | - |
| 494 | - layer = DatabaseFunctionalLayer |
| 495 | - |
| 496 | - def setUp(self): |
| 497 | - super(TestBugSubscriptionFilterTag, self).setUp() |
| 498 | - self.target = self.factory.makeProduct() |
| 499 | - self.subscriber = self.target.owner |
| 500 | - login_person(self.subscriber) |
| 501 | - self.subscription = self.target.addBugSubscription( |
| 502 | - self.subscriber, self.subscriber) |
| 503 | - self.subscription_filter = BugSubscriptionFilter() |
| 504 | - self.subscription_filter.structural_subscription = self.subscription |
| 505 | - |
| 506 | - def test_basics(self): |
| 507 | - """Test the basics of `BugSubscriptionFilterTag` objects.""" |
| 508 | - # Create. |
| 509 | - bug_sub_filter_tag = BugSubscriptionFilterTag() |
| 510 | - bug_sub_filter_tag.filter = self.subscription_filter |
| 511 | - bug_sub_filter_tag.include = True |
| 512 | - bug_sub_filter_tag.tag = u"foo" |
| 513 | - # Flush and reload. |
| 514 | - IStore(bug_sub_filter_tag).flush() |
| 515 | - IStore(bug_sub_filter_tag).reload(bug_sub_filter_tag) |
| 516 | - # Check. |
| 517 | - self.assertIsNot(None, bug_sub_filter_tag.id) |
| 518 | - self.assertEqual( |
| 519 | - self.subscription_filter.id, |
| 520 | - bug_sub_filter_tag.filter_id) |
| 521 | - self.assertEqual( |
| 522 | - self.subscription_filter, |
| 523 | - bug_sub_filter_tag.filter) |
| 524 | - self.assertIs(True, bug_sub_filter_tag.include) |
| 525 | - self.assertEqual(u"foo", bug_sub_filter_tag.tag) |
| 526 | - |
| 527 | - def test_qualified_tag(self): |
| 528 | - """ |
| 529 | - `BugSubscriptionFilterTag.qualified_tag` returns a tag with a |
| 530 | - preceding hyphen if `include` is `False`. |
| 531 | - """ |
| 532 | - bug_sub_filter_tag = BugSubscriptionFilterTag() |
| 533 | - bug_sub_filter_tag.tag = u"foo" |
| 534 | - bug_sub_filter_tag.include = True |
| 535 | - self.assertEqual(u"foo", bug_sub_filter_tag.qualified_tag) |
| 536 | - bug_sub_filter_tag.include = False |
| 537 | - self.assertEqual(u"-foo", bug_sub_filter_tag.qualified_tag) |
