← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:remove-enterpriseid into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:remove-enterpriseid into launchpad:master.

Commit message:
Remove lp.services.enterpriseid

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/387480

It was only used by the auditor client, which was recently removed.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:remove-enterpriseid into launchpad:master.
diff --git a/lib/lp/services/enterpriseid.py b/lib/lp/services/enterpriseid.py
deleted file mode 100644
index 69b0eee..0000000
--- a/lib/lp/services/enterpriseid.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# Copyright 2012-2013 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Enterprise ID utilities."""
-
-__metaclass__ = type
-__all__ = [
-    'object_to_enterpriseid',
-    'enterpriseids_to_objects',
-    ]
-
-from collections import defaultdict
-import os
-
-from lp.services.config import config
-from lp.services.database.bulk import load
-
-
-def object_to_enterpriseid(obj):
-    """Given an object, convert it to SOA Enterprise ID."""
-    otype = obj.__class__.__name__
-    instance = 'lp'
-    if config.devmode:
-        instance += '-development'
-    elif os.environ['LPCONFIG'] in ('dogfood', 'qastaing', 'staging'):
-        instance += '-%s' % os.environ['LPCONFIG']
-    return '%s:%s:%d' % (instance, otype, obj.id)
-
-
-def _known_types():
-    # Circular imports.
-    from lp.registry.model.person import Person
-    from lp.soyuz.model.queue import PackageUpload
-    return {
-        'PackageUpload': PackageUpload,
-        'Person': Person,
-    }
-
-
-def enterpriseids_to_objects(eids):
-    """Dereference multiple SOA Enterprise IDs."""
-    dbid_to_eid = defaultdict(dict)
-    for eid in eids:
-        if not eid.startswith('lp'):
-            raise TypeError
-        instance, cls, id = eid.split(':')
-        dbid_to_eid[cls][int(id)] = eid
-    types = _known_types()
-    eid_to_obj = {}
-    for kind in dbid_to_eid:
-        objs = load(types[kind], dbid_to_eid[kind].keys())
-        for obj in objs:
-            eid_to_obj[dbid_to_eid[kind][obj.id]] = obj
-    return eid_to_obj
diff --git a/lib/lp/services/tests/test_enterpriseid.py b/lib/lp/services/tests/test_enterpriseid.py
deleted file mode 100644
index eb6ca43..0000000
--- a/lib/lp/services/tests/test_enterpriseid.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright 2012-2013 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Test Enterprise ID utilities."""
-
-__metaclass__ = type
-
-from testtools.matchers import Equals
-
-from lp.services.database.interfaces import IStore
-from lp.services.enterpriseid import (
-    enterpriseids_to_objects,
-    object_to_enterpriseid,
-    )
-from lp.testing import (
-    StormStatementRecorder,
-    TestCaseWithFactory,
-    )
-from lp.testing.layers import LaunchpadFunctionalLayer
-from lp.testing.matchers import HasQueryCount
-
-
-class TestEnterpriseId(TestCaseWithFactory):
-    layer = LaunchpadFunctionalLayer
-
-    def test_object_to_enterpriseid(self):
-        person = self.factory.makePerson()
-        eid = object_to_enterpriseid(person)
-        expected = 'lp-development:Person:%d' % person.id
-        self.assertEqual(expected, eid)
-
-    def test_enterpriseids_to_objects(self):
-        expected = {}
-        for x in range(5):
-            person = self.factory.makePerson()
-            upload = self.factory.makePackageUpload()
-            expected['lp-development:Person:%d' % person.id] = person
-            expected['lp-development:PackageUpload:%d' % upload.id] = upload
-        IStore(expected.values()[0].__class__).invalidate()
-        with StormStatementRecorder() as recorder:
-            objects = enterpriseids_to_objects(expected.keys())
-        self.assertThat(recorder, HasQueryCount(Equals(2)))
-        self.assertContentEqual(expected.keys(), objects.keys())
-        self.assertContentEqual(expected.values(), objects.values())
-
-    def test_enterpriseids_to_objects_non_existent_id(self):
-        objects = enterpriseids_to_objects(
-            ['lp-development:PackageUpload:10000'])
-        self.assertEqual({}, objects)