Merge lp:~jcsackett/launchpad/add-enums-to-models into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Brad Crittenden on 2010-08-20 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 11410 |
| Proposed branch: | lp:~jcsackett/launchpad/add-enums-to-models |
| Merge into: | lp:launchpad |
| Prerequisite: | lp:~bac/launchpad/progress-enums |
| Diff against target: |
643 lines (+351/-54) 7 files modified
lib/lp/registry/browser/product.py (+3/-17) lib/lp/registry/configure.zcml (+4/-1) lib/lp/registry/doc/distribution.txt (+16/-3) lib/lp/registry/doc/product.txt (+0/-4) lib/lp/registry/model/distribution.py (+87/-21) lib/lp/registry/model/product.py (+67/-8) lib/lp/registry/tests/test_service_usage.py (+174/-0) |
| To merge this branch: | bzr merge lp:~jcsackett/launchpad/add-enums-to-models |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Brad Crittenden (community) | code | 2010-08-20 | Approve on 2010-08-20 |
|
Review via email:
|
|||
Commit Message
Wraps the usage_enums (e.g. official_
Description of the Change
= Summary =
IServiceUsage provides enums to give better data on how a product or distribution uses launchpad, in place of the old bool fields (e.g. official_rosetta). However, when we roll out these enums, they will default to UNKNOWN until we can migrate data.
This branch creates properties using the enums (moved to _[ENUM] format) to use the old bool data until data is set for the enum, so we can start using the enums in code.
== Proposed fix ==
Create properties using getters and setters to intelligent find the data from the new and old attributes, and set them properly moving forward.
== Pre-implementation notes ==
Talked with Curtis.
== Implementation details ==
As above.
This branch incorporates Brad's work on the progress bar, as they need to land together. ~bac/launchpad/
== Tests ==
bin/test -vvc -t UsageEnums
== Demo and Q/A ==
Go to a project on launchpad.dev and ensure the configuration and status
links are correct.
= Launchpad lint =
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
./lib/lp/
901: E301 expected 1 blank line, found 2
./lib/lp/
1181: E231 missing whitespace after ','
1185: E231 missing whitespace after ','
1197: E231 missing whitespace after ','
E301 from comment issue
E231 from creation of tuple (something = ('some tuple',))
| j.c.sackett (jcsackett) wrote : | # |
> In def test_codehostin
> Same question for def test_bug_
A bad job of refactoring early on? I must have just missed it when I moved the call to makeDistribution up into setUp.
>
> We discussed on IRC refactoring the tests since they are mostly the same.
There is now one BaseTestCase that does most of the work, with subclass that define the target to product or distribution.
Thanks for the pointers, Brad.
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -10,155 +10,17 @@
from lazr.lifecycle.
from lp.registry.
TestDistro
-from lp.app.enums import ServiceUsage
from lp.registry.
from lp.registry.
from lp.registry.
from lp.soyuz.
IDistribut
-from lp.testing import (
- login_person,
- TestCaseWithFac
- )
+from lp.testing import TestCaseWithFactory
from canonical.
DatabaseFu
-class TestDistributio
- """Tests the usage enums for the distribution."""
-
- layer = DatabaseFunctio
-
- def setUp(self):
- super(TestDistr
- self.distribution = self.factory.
-
- def test_answers_
- # By default, we don't know anything about a distribution
- self.assertEqual(
- ServiceUsage.
- self.distributi
-
- def test_answers_
- # If the old bool says they use Launchpad, return LAUNCHPAD
- # if the ServiceUsage is unknown.
- login_person(
- self.distributi
- self.assertEqual(
- ServiceUsage.
- self.distributi
-
- def test_answers_
- # If the enum has something other than UNKNOWN as its status,
- # use that.
- login_person(
- self.distributi
- self.assertEqual(
- ServiceUsage.
- self.distributi
-
- def test_answers_
- login_person(
- self.distributi
- self.distributi
- self.assertEqual(
- False,
- self.distributi
- self.distributi
- self.assertEqual(
- True,
- self.distributi
-
- def test_codehostin
- ...
| Robert Collins (lifeless) wrote : | # |
On Sat, Aug 21, 2010 at 9:58 AM, j.c.sackett
<email address hidden> wrote:
> +
> +# Manually create the TestLoader list, because the UsageEnumsBaseT
> +# shouldn't run.
> +test_list = [
> + __name__ + ".TestDistribut
> + __name__ + ".TestProductUs
> + ]
> +
> +
> +def test_suite():
> + return unittest.
There are a few slightly better ways of doing this.
Class UsageEnumsMixinIn
....stuff
class TestDistributio
...
class TestProductUsag
...
is one.
Another is to use testscenarios, and your parameterisation would be
more explicit, but we don't use that in lp today AFAIK, so I won't
suggest adding it in (but you could get much the same helpers from
bzrlib.testing).
These are better because they don't have a class that looks-to-loaders
like a valid test case, but isn't.
-Rob

Hi Jon,
In def test_codehostin g_usage( self): why do you make a new distribution instead of using self.distribution?
Same question for def test_bug_ tracking_ usage(self) :
We discussed on IRC refactoring the tests since they are mostly the same.
Otherwise this branch rocks. Look forward to seeing it landed.