← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/more-canonical-purge into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/more-canonical-purge into lp:launchpad with lp:~wgrant/launchpad/openpgpocalypse as a prerequisite.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/more-canonical-purge/+merge/85063

A few cleanups in canonical.launchpad:

 - a couple of HWDB tests and data files are moved into lp.hardwaredb
 - the remaining OpenID consumer stuff is moved into lp.services.openid alongside the rest
 - stormsugar is gone, as it was apparently never used.
-- 
https://code.launchpad.net/~wgrant/launchpad/more-canonical-purge/+merge/85063
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/more-canonical-purge into lp:launchpad.
=== modified file 'configs/testrunner/launchpad-lazr.conf'
--- configs/testrunner/launchpad-lazr.conf	2011-09-27 07:58:30 +0000
+++ configs/testrunner/launchpad-lazr.conf	2011-12-09 05:36:25 +0000
@@ -159,7 +159,7 @@
 buglist_batch_size: 20
 max_comment_size: 3200
 bugnotification_interval: 5
-debbugs_db_location: lib/canonical/launchpad/components/ftests/debbugs_db
+debbugs_db_location: lib/lp/bugs/tests/data/debbugs_db
 
 [memcache]
 servers: (127.0.0.1:11242,1)

=== removed directory 'lib/canonical/launchpad/components/ftests'
=== removed file 'lib/canonical/launchpad/components/ftests/__init__.py'
=== removed file 'lib/canonical/launchpad/database/stormsugar.py'
--- lib/canonical/launchpad/database/stormsugar.py	2010-11-05 09:23:08 +0000
+++ lib/canonical/launchpad/database/stormsugar.py	1970-01-01 00:00:00 +0000
@@ -1,135 +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=C0203
-
-"""Storm is powerful stuff.  This helps it go down more easily.
-
-This module is experimental.  Please give feedback and feel free to adjust it.
-"""
-
-__metaclass__ = type
-
-
-__all__ = [
-    'ForeignKey',
-    'ObjectNotFound',
-    'Sugar',
-    'UnknownProperty',
-    ]
-
-
-from storm.locals import (
-    Int,
-    Reference,
-    Store,
-    Storm,
-    )
-from zope.component import getUtility
-
-from canonical.launchpad.webapp.interfaces import (
-    DEFAULT_FLAVOR,
-    IStoreSelector,
-    MAIN_STORE,
-    MASTER_FLAVOR,
-    )
-from lp.app.errors import NotFoundError
-
-
-class ObjectNotFound(NotFoundError):
-    """Exception raised when a storm object can't be got."""
-
-    def __init__(self, orm_class, id):
-        msg = 'Not found: %s with id %s.' % (orm_class.__name__, id)
-        NotFoundError.__init__(self, msg)
-
-
-class UnknownProperty(Exception):
-    """The property name specified in a kwarg is not pre-defined."""
-
-    def __init__(self, orm_class, name):
-        msg = 'Class %s has no property "%s".' % (orm_class.__name__, name)
-        Exception.__init__(self, msg)
-
-
-class ForeignKey(Reference):
-
-    def __init__(self, remote_key, name=None):
-        self.name = name
-        Reference.__init__(self, None, remote_key)
-
-
-# Use Storm.__metaclass__ because storm.properties.PropertyPublisherMeta isn't
-# in an __all__.
-
-class Sugary(Storm.__metaclass__):
-    """Metaclass that adds support for ForeignKey."""
-
-    def __init__(cls, name, bases, dict):
-        for key in dir(cls):
-            val = getattr(cls, key, None)
-            if not isinstance(val, ForeignKey):
-                continue
-            col_name = val.name
-            if col_name is None:
-                col_name = key
-            val._local_key = Int(col_name)
-            setattr(cls, '_%s_id' % key, val._local_key)
-        # Do this last, because it wants References to have their local_key
-        # properly set up.
-        super(Sugary, cls).__init__(name, bases, dict)
-
-
-class Sugar(Storm):
-    """Base class providing convenient Storm API."""
-
-    __metaclass__ = Sugary
-
-    __store_type__ = MAIN_STORE
-
-    id = Int(primary=True)
-
-    def __init__(self, **kwargs):
-        super(Sugar).__init__(Sugar, self)
-        for key, value in kwargs.items():
-            if getattr(self.__class__, key, None) is None:
-                raise UnknownProperty(self.__class__, key)
-            setattr(self, key, value)
-        self.master_store.add(self)
-
-    @property
-    def master_store(self):
-        selector = getUtility(IStoreSelector)
-        return selector.get(self.__store_type__, MASTER_FLAVOR)
-
-    @classmethod
-    def getDefaultStore(klass):
-        """Return the default store for this class."""
-        selector = getUtility(IStoreSelector)
-        return selector.get(klass.__store_type__, DEFAULT_FLAVOR)
-
-    @classmethod
-    def getById(klass, id):
-        """Return the object of this type with given id."""
-        store = klass.getDefaultStore()
-        obj = store.get(klass, id)
-        if obj is None:
-            raise ObjectNotFound(klass, id)
-        return obj
-
-    @classmethod
-    def find(klass, **kwargs):
-        """Select the instances whose properties match kwargs."""
-        assert len(kwargs) > 0
-        store = klass.getDefaultStore()
-        return store.find(klass, **kwargs)
-
-    def flush(self):
-        """Bi-directionally update this object with the database."""
-        store = Store.of(self)
-        store.flush()
-        store.autoreload(self)
-
-    def remove(self):
-        """Remove this object from the database."""
-        Store.of(self).remove(self)

=== removed file 'lib/canonical/launchpad/database/tests/test_stormsugar.py'
--- lib/canonical/launchpad/database/tests/test_stormsugar.py	2011-08-12 11:37:08 +0000
+++ lib/canonical/launchpad/database/tests/test_stormsugar.py	1970-01-01 00:00:00 +0000
@@ -1,125 +0,0 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Tests for stormsugar."""
-
-__metaclass__ = type
-
-from psycopg2 import IntegrityError
-from storm.locals import (
-    Int,
-    Store,
-    )
-
-from canonical.launchpad.database.stormsugar import (
-    ForeignKey,
-    ObjectNotFound,
-    Sugar,
-    UnknownProperty,
-    )
-from canonical.testing.layers import DatabaseFunctionalLayer
-from lp.testing import TestCase
-
-
-class SugarDerived(Sugar):
-    """Class for testing.  (Because we can't test Sugar directly.)"""
-
-    __storm_table__ = 'Job'
-
-    status = Int()
-
-    progress = Int()
-
-
-class TestSugar(TestCase):
-
-    layer = DatabaseFunctionalLayer
-
-    def test_init_adds(self):
-        """Default constructor adds to store."""
-        created = SugarDerived(id=500, status=0)
-        self.assertIs(created.master_store, Store.of(created))
-
-    def test_init_handles_kwargs(self):
-        """Default constructor handles kwargs."""
-        created = SugarDerived(id=500, status=0)
-        self.assertEqual(500, created.id)
-        self.assertEqual(0, created.status)
-
-    def test_init_requires_known_kwargs(self):
-        """Default constructor requires pre-defined kwargs.
-
-        (This reduces the potential for typos to cause confusion or bugs.)
-        """
-        e = self.assertRaises(
-            UnknownProperty, SugarDerived, id=500, status=0, foo='bar')
-        self.assertEqual('Class SugarDerived has no property "foo".', str(e))
-
-    def test_getById(self):
-        """Get either returns the desired object or raises."""
-        e = self.assertRaises(ObjectNotFound, SugarDerived.getById, 500)
-        self.assertEqual("'Not found: SugarDerived with id 500.'", str(e))
-        created = SugarDerived(id=500, status=0)
-        gotten = SugarDerived.getById(500)
-        self.assertEqual(created, gotten)
-
-    def test_remove(self):
-        """destroySelf destroys the object in question."""
-        created = SugarDerived(id=500, status=0)
-        created.remove()
-        self.assertRaises(ObjectNotFound, SugarDerived.getById, 500)
-
-    def test_flush_exercises_constraints(self):
-        """Sugar.flush causes constraints to be tested."""
-        created = SugarDerived(id=500)
-        # The IntegrityError is raised because status is not set, and it
-        # has the NOT NULL constraint.
-        self.assertRaises(IntegrityError, created.flush)
-
-    def test_find(self):
-        """Sugar.find works."""
-        obj1 = SugarDerived(id=500, status=5)
-        obj2 = SugarDerived(id=501, status=6)
-        self.assertEqual([obj1], list(SugarDerived.find(status=5)))
-        self.assertEqual([], list(SugarDerived.find(status=4)))
-        self.assertRaises(AssertionError, SugarDerived.find)
-
-    def test_find_with_multiple_clauses(self):
-        """Multiple kwargs are ANDed."""
-        obj1 = SugarDerived(status=5, progress=1)
-        obj2 = SugarDerived(status=5, progress=2)
-        obj3 = SugarDerived(status=6, progress=2)
-        self.assertEqual(
-            [obj1], list(SugarDerived.find(status=5, progress=1)))
-        self.assertEqual(
-            [obj2], list(SugarDerived.find(status=5, progress=2)))
-        self.assertEqual(
-            [obj3], list(SugarDerived.find(status=6, progress=2)))
-
-    def test_ForeignKey(self):
-        """ForeignKey works, and defaults to property name."""
-
-        class ReferencingObject(Sugar):
-
-            __storm_table__ = 'BranchJob'
-
-            job = ForeignKey(SugarDerived.id)
-
-        obj1 = SugarDerived(status=0)
-        obj2 = ReferencingObject(job=obj1)
-        self.assertEqual(obj1, obj2.job)
-        self.assertEqual(obj1.id, obj2._job_id)
-
-    def test_ForeignKey_with_name(self):
-        """ForeignKey name correctly overrides property name."""
-
-        class ReferencingObjectWithName(Sugar):
-
-            __storm_table__ = 'BranchJob'
-
-            foo = ForeignKey(SugarDerived.id, 'job')
-
-        obj1 = SugarDerived(status=0)
-        obj2 = ReferencingObjectWithName(foo=obj1)
-        self.assertEqual(obj1, obj2.foo)
-        self.assertEqual(obj1.id, obj2._foo_id)

=== modified file 'lib/canonical/launchpad/webapp/login.py'
--- lib/canonical/launchpad/webapp/login.py	2011-12-08 04:36:31 +0000
+++ lib/canonical/launchpad/webapp/login.py	2011-12-09 05:36:25 +0000
@@ -41,7 +41,6 @@
 from canonical.config import config
 from canonical.launchpad import _
 from canonical.launchpad.interfaces.account import AccountSuspendedError
-from canonical.launchpad.interfaces.openidconsumer import IOpenIDConsumerStore
 from canonical.launchpad.readonly import is_read_only
 from canonical.launchpad.webapp.dbpolicy import MasterDatabasePolicy
 from canonical.launchpad.webapp.error import SystemErrorView
@@ -60,6 +59,7 @@
     IPersonSet,
     PersonCreationRationale,
     )
+from lp.services.openid.interfaces.openidconsumer import IOpenIDConsumerStore
 from lp.services.propertycache import cachedproperty
 from lp.services.timeline.requesttimeline import get_request_timeline
 

=== modified file 'lib/canonical/launchpad/zcml/configure.zcml'
--- lib/canonical/launchpad/zcml/configure.zcml	2011-12-09 05:36:25 +0000
+++ lib/canonical/launchpad/zcml/configure.zcml	2011-12-09 05:36:25 +0000
@@ -19,7 +19,6 @@
     <include file="librarian.zcml" />
     <include file="lifecycle.zcml" />
     <include file="logintoken.zcml" />
-    <include file="openidconsumer.zcml" />
     <include file="temporaryblobstorage.zcml" />
     <include file="webservice.zcml" />
 

=== removed file 'lib/canonical/launchpad/zcml/openidconsumer.zcml'
--- lib/canonical/launchpad/zcml/openidconsumer.zcml	2009-07-13 18:15:02 +0000
+++ lib/canonical/launchpad/zcml/openidconsumer.zcml	1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
-<!-- Copyright 2009 Canonical Ltd.  This software is licensed under the
-     GNU Affero General Public License version 3 (see the file LICENSE).
--->
-
-<configure xmlns="http://namespaces.zope.org/zope";>
-
-  <utility
-      provides="..interfaces.openidconsumer.IOpenIDConsumerStore"
-      factory="..database.openidconsumer.OpenIDConsumerStore">
-  </utility>
-
-</configure>

=== modified file 'lib/lp/bugs/doc/externalbugtracker-debbugs.txt'
--- lib/lp/bugs/doc/externalbugtracker-debbugs.txt	2011-05-27 19:53:20 +0000
+++ lib/lp/bugs/doc/externalbugtracker-debbugs.txt	2011-12-09 05:36:25 +0000
@@ -7,9 +7,9 @@
 
     >>> import os.path
     >>> from canonical.config import config
-    >>> from canonical.launchpad.components.ftests import __file__
+    >>> from lp.bugs.tests import __file__
     >>> test_db_location = os.path.join(
-    ...     os.path.dirname(__file__), 'debbugs_db')
+    ...     os.path.dirname(__file__), 'data/debbugs_db')
 
 You can specify the db_location explicitly:
 

=== added directory 'lib/lp/bugs/tests/data'
=== renamed directory 'lib/canonical/launchpad/components/ftests/debbugs_db' => 'lib/lp/bugs/tests/data/debbugs_db'
=== modified file 'lib/lp/hardwaredb/doc/hwdb-submission.txt'
--- lib/lp/hardwaredb/doc/hwdb-submission.txt	2010-10-18 22:24:59 +0000
+++ lib/lp/hardwaredb/doc/hwdb-submission.txt	2011-12-09 05:36:25 +0000
@@ -201,7 +201,7 @@
     >>> team_form['field.submission_key'] = u'unique-id-68'
     >>> valid_sample_data_path = os.path.join(
     ...     config.root,
-    ...     'lib/canonical/launchpad/scripts/tests/'
+    ...     'lib/lp/hardwaredb/scripts/tests/'
     ...     'simple_valid_hwdb_submission.xml')
     >>> valid_sample_data = StringIO(open(valid_sample_data_path).read())
     >>> valid_sample_data.filename = 'simple_valid_hwdb_submission.xml'

=== renamed file 'lib/canonical/launchpad/scripts/tests/simple_valid_hwdb_submission.xml' => 'lib/lp/hardwaredb/scripts/tests/simple_valid_hwdb_submission.xml'
=== renamed file 'lib/canonical/launchpad/scripts/tests/test_hwdb_submission_parser.py' => 'lib/lp/hardwaredb/scripts/tests/test_hwdb_submission_parser.py'
=== renamed file 'lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py' => 'lib/lp/hardwaredb/scripts/tests/test_hwdb_submission_processing.py'
--- lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py	2011-11-16 06:15:58 +0000
+++ lib/lp/hardwaredb/scripts/tests/test_hwdb_submission_processing.py	2011-12-09 05:36:25 +0000
@@ -5101,7 +5101,7 @@
     def getSampleData(self, filename):
         """Return the submission data of a short valid submission."""
         sample_data_path = os.path.join(
-            config.root, 'lib', 'canonical', 'launchpad', 'scripts',
+            config.root, 'lib', 'lp', 'hardwaredb', 'scripts',
             'tests', 'simple_valid_hwdb_submission.xml')
         return open(sample_data_path).read()
 

=== modified file 'lib/lp/scripts/garbo.py'
--- lib/lp/scripts/garbo.py	2011-12-08 05:13:31 +0000
+++ lib/lp/scripts/garbo.py	2011-12-09 05:36:25 +0000
@@ -46,7 +46,6 @@
 from canonical.launchpad.database.emailaddress import EmailAddress
 from canonical.launchpad.database.librarian import TimeLimitedToken
 from canonical.launchpad.database.logintoken import LoginToken
-from canonical.launchpad.database.openidconsumer import OpenIDConsumerNonce
 from canonical.launchpad.interfaces.account import AccountStatus
 from canonical.launchpad.interfaces.emailaddress import EmailAddressStatus
 from canonical.launchpad.interfaces.lpstorm import IMasterStore
@@ -78,6 +77,7 @@
 from lp.services.job.model.job import Job
 from lp.services.log.logger import PrefixFilter
 from lp.services.oauth.model import OAuthNonce
+from lp.services.openid.model.openidconsumer import OpenIDConsumerNonce
 from lp.services.propertycache import cachedproperty
 from lp.services.scripts.base import (
     LaunchpadCronScript,

=== modified file 'lib/lp/scripts/tests/test_garbo.py'
--- lib/lp/scripts/tests/test_garbo.py	2011-12-08 05:13:31 +0000
+++ lib/lp/scripts/tests/test_garbo.py	2011-12-09 05:36:25 +0000
@@ -44,7 +44,6 @@
     )
 from canonical.launchpad.database.librarian import TimeLimitedToken
 from canonical.launchpad.database.logintoken import LoginToken
-from canonical.launchpad.database.openidconsumer import OpenIDConsumerNonce
 from canonical.launchpad.interfaces.account import AccountStatus
 from canonical.launchpad.interfaces.authtoken import LoginTokenType
 from canonical.launchpad.interfaces.emailaddress import EmailAddressStatus
@@ -100,6 +99,7 @@
     OAuthAccessToken,
     OAuthNonce,
     )
+from lp.services.openid.model.openidconsumer import OpenIDConsumerNonce
 from lp.services.session.model import (
     SessionData,
     SessionPkgData,

=== modified file 'lib/lp/services/openid/configure.zcml'
--- lib/lp/services/openid/configure.zcml	2011-09-04 12:46:14 +0000
+++ lib/lp/services/openid/configure.zcml	2011-12-09 05:36:25 +0000
@@ -21,4 +21,8 @@
     <adapter factory=".adapters.openid.OpenIDPersistentIdentity" />
     <adapter factory=".adapters.openid.person_to_openidpersistentidentity" />
 
+    <utility
+        provides=".interfaces.openidconsumer.IOpenIDConsumerStore"
+        factory=".model.openidconsumer.OpenIDConsumerStore" />
+
 </configure>

=== renamed file 'lib/canonical/launchpad/interfaces/openidconsumer.py' => 'lib/lp/services/openid/interfaces/openidconsumer.py'
=== renamed file 'lib/canonical/launchpad/database/baseopenidstore.py' => 'lib/lp/services/openid/model/baseopenidstore.py'
=== renamed file 'lib/canonical/launchpad/database/openidconsumer.py' => 'lib/lp/services/openid/model/openidconsumer.py'
--- lib/canonical/launchpad/database/openidconsumer.py	2010-08-20 20:31:18 +0000
+++ lib/lp/services/openid/model/openidconsumer.py	2011-12-09 05:36:25 +0000
@@ -8,12 +8,12 @@
 
 from zope.interface import implements
 
-from canonical.launchpad.database.baseopenidstore import (
+from lp.services.openid.interfaces.openidconsumer import IOpenIDConsumerStore
+from lp.services.openid.model.baseopenidstore import (
     BaseStormOpenIDAssociation,
     BaseStormOpenIDNonce,
     BaseStormOpenIDStore,
     )
-from canonical.launchpad.interfaces.openidconsumer import IOpenIDConsumerStore
 
 
 class OpenIDConsumerAssociation(BaseStormOpenIDAssociation):

=== renamed file 'lib/canonical/launchpad/database/tests/test_baseopenidstore.py' => 'lib/lp/services/openid/tests/test_baseopenidstore.py'
--- lib/canonical/launchpad/database/tests/test_baseopenidstore.py	2010-08-20 20:31:18 +0000
+++ lib/lp/services/openid/tests/test_baseopenidstore.py	2011-12-09 05:36:25 +0000
@@ -14,8 +14,8 @@
 from openid.association import Association
 from openid.store import nonce
 
-from canonical.launchpad.database.baseopenidstore import BaseStormOpenIDStore
 from canonical.launchpad.interfaces.lpstorm import IMasterStore
+from lp.services.openid.model.baseopenidstore import BaseStormOpenIDStore
 
 
 class BaseStormOpenIDStoreTestsMixin:

=== renamed file 'lib/canonical/launchpad/database/tests/test_openidconsumer.py' => 'lib/lp/services/openid/tests/test_openidconsumer.py'
--- lib/canonical/launchpad/database/tests/test_openidconsumer.py	2011-08-12 11:37:08 +0000
+++ lib/lp/services/openid/tests/test_openidconsumer.py	2011-12-09 05:36:25 +0000
@@ -7,11 +7,11 @@
 
 from zope.component import getUtility
 
-from canonical.launchpad.database.tests.test_baseopenidstore import (
+from canonical.testing.layers import DatabaseFunctionalLayer
+from lp.services.openid.interfaces.openidconsumer import IOpenIDConsumerStore
+from lp.services.openid.tests.test_baseopenidstore import (
     BaseStormOpenIDStoreTestsMixin,
     )
-from canonical.launchpad.interfaces.openidconsumer import IOpenIDConsumerStore
-from canonical.testing.layers import DatabaseFunctionalLayer
 from lp.testing import TestCase
 
 

=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py	2011-12-09 05:36:25 +0000
+++ lib/lp/testing/factory.py	2011-12-09 05:36:25 +0000
@@ -4209,7 +4209,7 @@
             system = self.getUniqueString('system-fingerprint')
         if submission_data is None:
             sample_data_path = os.path.join(
-                config.root, 'lib', 'canonical', 'launchpad', 'scripts',
+                config.root, 'lib', 'lp', 'hardwaredb', 'scripts',
                 'tests', 'simple_valid_hwdb_submission.xml')
             submission_data = open(sample_data_path).read()
         filename = self.getUniqueString('submission-file')