Merge lp:~stevenk/launchpad/destroy-bprc into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: William Grant
Approved revision: no longer in the source branch.
Merged at revision: 15472
Proposed branch: lp:~stevenk/launchpad/destroy-bprc
Merge into: lp:launchpad
Diff against target: 354 lines (+0/-314)
7 files modified
lib/lp/soyuz/configure.zcml (+0/-34)
lib/lp/soyuz/interfaces/binarypackagepath.py (+0/-36)
lib/lp/soyuz/interfaces/binarypackagereleasecontents.py (+0/-45)
lib/lp/soyuz/model/binarypackagepath.py (+0/-37)
lib/lp/soyuz/model/binarypackagereleasecontents.py (+0/-71)
lib/lp/soyuz/tests/test_binarypackagepath.py (+0/-26)
lib/lp/soyuz/tests/test_binarypackagereleasecontents.py (+0/-65)
To merge this branch: bzr merge lp:~stevenk/launchpad/destroy-bprc
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+111542@code.launchpad.net

Commit message

Delete the model, interfaces and tests for BinaryPackageReleaseContents and BinaryPackagePath.

Description of the change

Delete the model, interfaces and tests for BinaryPackageReleaseContents and BinaryPackagePath. This was an effort to do contents generation from the DB, but the effort was mostly stillborn and I think it should be dropped.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/soyuz/configure.zcml'
--- lib/lp/soyuz/configure.zcml 2012-06-19 16:09:38 +0000
+++ lib/lp/soyuz/configure.zcml 2012-06-22 05:32:21 +0000
@@ -993,40 +993,6 @@
993 <allow interface="lp.soyuz.adapters.overrides.IOverridePolicy" />993 <allow interface="lp.soyuz.adapters.overrides.IOverridePolicy" />
994 </class>994 </class>
995995
996 <!-- BinaryPackagePath -->
997
998 <class
999 class="lp.soyuz.model.binarypackagepath.BinaryPackagePath">
1000 <allow
1001 interface="lp.soyuz.interfaces.binarypackagepath.IBinaryPackagePath"/>
1002 </class>
1003
1004 <!-- BinaryPackagePathSet -->
1005
1006 <securedutility
1007 class="lp.soyuz.model.binarypackagepath.BinaryPackagePath"
1008 provides="lp.soyuz.interfaces.binarypackagepath.IBinaryPackagePathSet">
1009 <allow
1010 interface="lp.soyuz.interfaces.binarypackagepath.IBinaryPackagePathSet"/>
1011 </securedutility>
1012
1013 <!-- BinaryPackageReleaseContents -->
1014
1015 <class
1016 class="lp.soyuz.model.binarypackagereleasecontents.BinaryPackageReleaseContents">
1017 <allow
1018 interface="lp.soyuz.interfaces.binarypackagereleasecontents.IBinaryPackageReleaseContents"/>
1019 </class>
1020
1021 <!-- BinaryPackageReleaseContentsSet -->
1022
1023 <securedutility
1024 class="lp.soyuz.model.binarypackagereleasecontents.BinaryPackageReleaseContents"
1025 provides="lp.soyuz.interfaces.binarypackagereleasecontents.IBinaryPackageReleaseContentsSet">
1026 <allow
1027 interface="lp.soyuz.interfaces.binarypackagereleasecontents.IBinaryPackageReleaseContentsSet"/>
1028 </securedutility>
1029
1030 <webservice:register module="lp.soyuz.interfaces.webservice" />996 <webservice:register module="lp.soyuz.interfaces.webservice" />
1031997
1032</configure>998</configure>
1033999
=== removed file 'lib/lp/soyuz/interfaces/binarypackagepath.py'
--- lib/lp/soyuz/interfaces/binarypackagepath.py 2011-12-24 16:54:44 +0000
+++ lib/lp/soyuz/interfaces/binarypackagepath.py 1970-01-01 00:00:00 +0000
@@ -1,36 +0,0 @@
1# Copyright 2011 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""Binary Package Path interface."""
5
6__metaclass__ = type
7
8__all__ = [
9 'IBinaryPackagePath',
10 'IBinaryPackagePathSet',
11 ]
12
13from zope.interface import Interface
14from zope.schema import (
15 Int,
16 TextLine,
17 )
18
19from lp import _
20
21
22class IBinaryPackagePath(Interface):
23 """The path of a file contained in a binary package."""
24 id = Int(title=_('ID'), required=True, readonly=True)
25 path = TextLine(title=_('Full path name'), required=True, readonly=True)
26
27
28class IBinaryPackagePathSet(Interface):
29
30 def getOrCreate(path):
31 """Fetch the ID of the given path name, or create it.
32
33 :param: path: The full path name to query or create.
34
35 :return: A `IBinaryPackagePath`.
36 """
370
=== removed file 'lib/lp/soyuz/interfaces/binarypackagereleasecontents.py'
--- lib/lp/soyuz/interfaces/binarypackagereleasecontents.py 2011-12-24 16:54:44 +0000
+++ lib/lp/soyuz/interfaces/binarypackagereleasecontents.py 1970-01-01 00:00:00 +0000
@@ -1,45 +0,0 @@
1# Copyright 2011 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""Binary Package Release Contents interface."""
5
6__metaclass__ = type
7
8__all__ = [
9 'IBinaryPackageReleaseContents',
10 'IBinaryPackageReleaseContentsSet',
11 ]
12
13from lazr.restful.fields import Reference
14from zope.interface import Interface
15
16from lp import _
17from lp.soyuz.interfaces.binarypackagepath import IBinaryPackagePath
18from lp.soyuz.interfaces.binarypackagerelease import IBinaryPackageRelease
19
20
21class IBinaryPackageReleaseContents(Interface):
22 """A file contained by an `IBinaryPackageRelease`."""
23 binarypackagerelease = Reference(
24 IBinaryPackageRelease, title=_('Binary Package Release'),
25 required=True, readonly=True)
26 binarypackagepath = Reference(
27 IBinaryPackagePath, title=_('Binary Package Pathname'),
28 required=True, readonly=True)
29
30
31class IBinaryPackageReleaseContentsSet(Interface):
32
33 def add(bpr):
34 """Add the contents of the given binary package release.
35
36 :param: bpr: The `IBinaryPackageRelease` to add.
37
38 :return: True on success, False on failure.
39 """
40
41 def remove(bpr):
42 """Remove the contents of the given binary package release.
43
44 :param: bpr: The `IBinaryPackageRelease` to remove.
45 """
460
=== removed file 'lib/lp/soyuz/model/binarypackagepath.py'
--- lib/lp/soyuz/model/binarypackagepath.py 2011-12-21 14:58:31 +0000
+++ lib/lp/soyuz/model/binarypackagepath.py 1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4__metaclass__ = type
5
6__all__ = [
7 'BinaryPackagePath',
8 ]
9
10from storm.locals import (
11 Int,
12 RawStr,
13 Storm,
14 )
15from zope.interface import implements
16
17from lp.services.database.lpstorm import IMasterStore
18from lp.soyuz.interfaces.binarypackagepath import IBinaryPackagePath
19
20
21class BinaryPackagePath(Storm):
22 """See `IBinaryPackagePath`."""
23 implements(IBinaryPackagePath)
24 __storm_table__ = 'BinaryPackagePath'
25 id = Int(primary=True)
26 path = RawStr(name='path', allow_none=False)
27
28 def getOrCreate(self, path):
29 """See `IBinaryPackagePathSet`."""
30 store = IMasterStore(BinaryPackagePath)
31 bpp = store.find(
32 BinaryPackagePath, BinaryPackagePath.path == path).one()
33 if bpp is None:
34 bpp = BinaryPackagePath()
35 bpp.path = path
36 store.add(bpp)
37 return bpp
380
=== removed file 'lib/lp/soyuz/model/binarypackagereleasecontents.py'
--- lib/lp/soyuz/model/binarypackagereleasecontents.py 2011-12-21 14:58:31 +0000
+++ lib/lp/soyuz/model/binarypackagereleasecontents.py 1970-01-01 00:00:00 +0000
@@ -1,71 +0,0 @@
1# Copyright 2011 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4__metaclass__ = type
5
6__all__ = [
7 'BinaryPackageReleaseContents',
8 ]
9
10import tempfile
11
12from apt.debfile import DebPackage
13from bzrlib.osutils import pumpfile
14from storm.locals import (
15 Int,
16 Reference,
17 Storm,
18 )
19from zope.component import getUtility
20from zope.interface import implements
21
22from lp.services.database.lpstorm import IMasterStore
23from lp.soyuz.interfaces.binarypackagepath import IBinaryPackagePathSet
24from lp.soyuz.interfaces.binarypackagereleasecontents import (
25 IBinaryPackageReleaseContents,
26 )
27
28
29class BinaryPackageReleaseContents(Storm):
30 """See `IBinaryPackageReleaseContents`."""
31 implements(IBinaryPackageReleaseContents)
32 __storm_table__ = 'BinaryPackageReleaseContents'
33 __storm_primary__ = ("binarypackagerelease_id", "binarypackagepath_id")
34
35 binarypackagerelease_id = Int(
36 name='binarypackagerelease', allow_none=False)
37 binarypackagerelease = Reference(
38 binarypackagerelease_id, 'BinaryPackageRelease.id')
39
40 binarypackagepath_id = Int(name='binarypackagepath', allow_none=False)
41 binarypackagepath = Reference(
42 binarypackagepath_id, 'BinaryPackagePath.id')
43
44 def add(self, bpr):
45 """See `IBinaryPackageReleaseContentsSet`."""
46 if not bpr.files:
47 return False
48 store = IMasterStore(BinaryPackageReleaseContents)
49 with tempfile.NamedTemporaryFile() as dest_file:
50 bpr.files[0].libraryfile.open()
51 pumpfile(bpr.files[0].libraryfile, dest_file)
52 dest_file.seek(0)
53 deb = DebPackage(filename=dest_file.name)
54 # Filter out directories.
55 filelist = filter(lambda x: not x.endswith('/'), deb.filelist)
56 for filename in filelist:
57 bpp = getUtility(IBinaryPackagePathSet).getOrCreate(
58 filename)
59 bprc = BinaryPackageReleaseContents()
60 bprc.binarypackagerelease = bpr
61 bprc.binarypackagepath = bpp
62 store.add(bprc)
63 return True
64
65 def remove(self, bpr):
66 """See `IBinaryPackageReleaseContentsSet`."""
67 store = IMasterStore(BinaryPackageReleaseContents)
68 results = store.find(
69 BinaryPackageReleaseContents,
70 BinaryPackageReleaseContents.binarypackagerelease == bpr.id)
71 results.remove()
720
=== removed file 'lib/lp/soyuz/tests/test_binarypackagepath.py'
--- lib/lp/soyuz/tests/test_binarypackagepath.py 2012-01-01 02:58:52 +0000
+++ lib/lp/soyuz/tests/test_binarypackagepath.py 1970-01-01 00:00:00 +0000
@@ -1,26 +0,0 @@
1# Copyright 2011 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""Test the Binary Package Path model."""
5
6__metaclass__ = type
7
8from zope.component import getUtility
9
10from lp.soyuz.interfaces.binarypackagepath import IBinaryPackagePathSet
11from lp.testing import TestCaseWithFactory
12from lp.testing.layers import DatabaseFunctionalLayer
13
14
15class TestBinaryPackagePath(TestCaseWithFactory):
16
17 layer = DatabaseFunctionalLayer
18
19 def test_getOrCreate(self):
20 bpp = getUtility(IBinaryPackagePathSet).getOrCreate('bin/bash')
21 self.assertEqual('bin/bash', bpp.path)
22
23 def test_getOrCreate_existing(self):
24 orig_bpp = getUtility(IBinaryPackagePathSet).getOrCreate('bin/bash')
25 bpp = getUtility(IBinaryPackagePathSet).getOrCreate('bin/bash')
26 self.assertEqual(orig_bpp.id, bpp.id)
270
=== removed file 'lib/lp/soyuz/tests/test_binarypackagereleasecontents.py'
--- lib/lp/soyuz/tests/test_binarypackagereleasecontents.py 2012-01-01 02:58:52 +0000
+++ lib/lp/soyuz/tests/test_binarypackagereleasecontents.py 1970-01-01 00:00:00 +0000
@@ -1,65 +0,0 @@
1# Copyright 2011 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""Test the Binary Package Release Contents model."""
5
6__metaclass__ = type
7
8import transaction
9from zope.component import getUtility
10
11from lp.archiveuploader.tests import datadir
12from lp.services.database.lpstorm import IStore
13from lp.soyuz.interfaces.binarypackagereleasecontents import (
14 IBinaryPackageReleaseContentsSet,
15 )
16from lp.soyuz.model.binarypackagereleasecontents import (
17 BinaryPackageReleaseContents,
18 )
19from lp.testing import TestCaseWithFactory
20from lp.testing.layers import LaunchpadFunctionalLayer
21
22
23class TestBinaryPackageReleaseContents(TestCaseWithFactory):
24
25 layer = LaunchpadFunctionalLayer
26
27 def create_bpr(self):
28 bpr = self.factory.makeBinaryPackageRelease()
29 deb = open(datadir('pmount_0.9.7-2ubuntu2_amd64.deb'), 'r')
30 lfa = self.factory.makeLibraryFileAlias(
31 filename='pmount_0.9.7-2ubuntu2_amd64.deb', content=deb.read())
32 deb.close()
33 transaction.commit()
34 bpr.addFile(lfa)
35 return bpr
36
37 def test_add(self):
38 bpr = self.create_bpr()
39 getUtility(IBinaryPackageReleaseContentsSet).add(bpr)
40 store = IStore(BinaryPackageReleaseContents)
41 results = store.find(
42 BinaryPackageReleaseContents,
43 BinaryPackageReleaseContents.binarypackagerelease == bpr.id)
44 paths = map(lambda x: x.binarypackagepath.path, results)
45 expected_paths = [
46 'etc/pmount.allow', 'usr/bin/pumount', 'usr/bin/pmount-hal',
47 'usr/bin/pmount', 'usr/share/doc/pmount/TODO',
48 'usr/share/doc/pmount/README.Debian',
49 'usr/share/doc/pmount/AUTHORS', 'usr/share/doc/pmount/copyright',
50 'usr/share/doc/pmount/changelog.gz',
51 'usr/share/doc/pmount/changelog.Debian.gz',
52 'usr/share/man/man1/pmount-hal.1.gz',
53 'usr/share/man/man1/pmount.1.gz',
54 'usr/share/man/man1/pumount.1.gz']
55 self.assertContentEqual(expected_paths, paths)
56
57 def test_remove(self):
58 bpr = self.create_bpr()
59 getUtility(IBinaryPackageReleaseContentsSet).add(bpr)
60 getUtility(IBinaryPackageReleaseContentsSet).remove(bpr)
61 store = IStore(BinaryPackageReleaseContents)
62 results = store.find(
63 BinaryPackageReleaseContents,
64 BinaryPackageReleaseContents.binarypackagerelease == bpr.id)
65 self.assertEqual(0, results.count())