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
1=== modified file 'lib/lp/soyuz/configure.zcml'
2--- lib/lp/soyuz/configure.zcml 2012-06-19 16:09:38 +0000
3+++ lib/lp/soyuz/configure.zcml 2012-06-22 05:32:21 +0000
4@@ -993,40 +993,6 @@
5 <allow interface="lp.soyuz.adapters.overrides.IOverridePolicy" />
6 </class>
7
8- <!-- BinaryPackagePath -->
9-
10- <class
11- class="lp.soyuz.model.binarypackagepath.BinaryPackagePath">
12- <allow
13- interface="lp.soyuz.interfaces.binarypackagepath.IBinaryPackagePath"/>
14- </class>
15-
16- <!-- BinaryPackagePathSet -->
17-
18- <securedutility
19- class="lp.soyuz.model.binarypackagepath.BinaryPackagePath"
20- provides="lp.soyuz.interfaces.binarypackagepath.IBinaryPackagePathSet">
21- <allow
22- interface="lp.soyuz.interfaces.binarypackagepath.IBinaryPackagePathSet"/>
23- </securedutility>
24-
25- <!-- BinaryPackageReleaseContents -->
26-
27- <class
28- class="lp.soyuz.model.binarypackagereleasecontents.BinaryPackageReleaseContents">
29- <allow
30- interface="lp.soyuz.interfaces.binarypackagereleasecontents.IBinaryPackageReleaseContents"/>
31- </class>
32-
33- <!-- BinaryPackageReleaseContentsSet -->
34-
35- <securedutility
36- class="lp.soyuz.model.binarypackagereleasecontents.BinaryPackageReleaseContents"
37- provides="lp.soyuz.interfaces.binarypackagereleasecontents.IBinaryPackageReleaseContentsSet">
38- <allow
39- interface="lp.soyuz.interfaces.binarypackagereleasecontents.IBinaryPackageReleaseContentsSet"/>
40- </securedutility>
41-
42 <webservice:register module="lp.soyuz.interfaces.webservice" />
43
44 </configure>
45
46=== removed file 'lib/lp/soyuz/interfaces/binarypackagepath.py'
47--- lib/lp/soyuz/interfaces/binarypackagepath.py 2011-12-24 16:54:44 +0000
48+++ lib/lp/soyuz/interfaces/binarypackagepath.py 1970-01-01 00:00:00 +0000
49@@ -1,36 +0,0 @@
50-# Copyright 2011 Canonical Ltd. This software is licensed under the
51-# GNU Affero General Public License version 3 (see the file LICENSE).
52-
53-"""Binary Package Path interface."""
54-
55-__metaclass__ = type
56-
57-__all__ = [
58- 'IBinaryPackagePath',
59- 'IBinaryPackagePathSet',
60- ]
61-
62-from zope.interface import Interface
63-from zope.schema import (
64- Int,
65- TextLine,
66- )
67-
68-from lp import _
69-
70-
71-class IBinaryPackagePath(Interface):
72- """The path of a file contained in a binary package."""
73- id = Int(title=_('ID'), required=True, readonly=True)
74- path = TextLine(title=_('Full path name'), required=True, readonly=True)
75-
76-
77-class IBinaryPackagePathSet(Interface):
78-
79- def getOrCreate(path):
80- """Fetch the ID of the given path name, or create it.
81-
82- :param: path: The full path name to query or create.
83-
84- :return: A `IBinaryPackagePath`.
85- """
86
87=== removed file 'lib/lp/soyuz/interfaces/binarypackagereleasecontents.py'
88--- lib/lp/soyuz/interfaces/binarypackagereleasecontents.py 2011-12-24 16:54:44 +0000
89+++ lib/lp/soyuz/interfaces/binarypackagereleasecontents.py 1970-01-01 00:00:00 +0000
90@@ -1,45 +0,0 @@
91-# Copyright 2011 Canonical Ltd. This software is licensed under the
92-# GNU Affero General Public License version 3 (see the file LICENSE).
93-
94-"""Binary Package Release Contents interface."""
95-
96-__metaclass__ = type
97-
98-__all__ = [
99- 'IBinaryPackageReleaseContents',
100- 'IBinaryPackageReleaseContentsSet',
101- ]
102-
103-from lazr.restful.fields import Reference
104-from zope.interface import Interface
105-
106-from lp import _
107-from lp.soyuz.interfaces.binarypackagepath import IBinaryPackagePath
108-from lp.soyuz.interfaces.binarypackagerelease import IBinaryPackageRelease
109-
110-
111-class IBinaryPackageReleaseContents(Interface):
112- """A file contained by an `IBinaryPackageRelease`."""
113- binarypackagerelease = Reference(
114- IBinaryPackageRelease, title=_('Binary Package Release'),
115- required=True, readonly=True)
116- binarypackagepath = Reference(
117- IBinaryPackagePath, title=_('Binary Package Pathname'),
118- required=True, readonly=True)
119-
120-
121-class IBinaryPackageReleaseContentsSet(Interface):
122-
123- def add(bpr):
124- """Add the contents of the given binary package release.
125-
126- :param: bpr: The `IBinaryPackageRelease` to add.
127-
128- :return: True on success, False on failure.
129- """
130-
131- def remove(bpr):
132- """Remove the contents of the given binary package release.
133-
134- :param: bpr: The `IBinaryPackageRelease` to remove.
135- """
136
137=== removed file 'lib/lp/soyuz/model/binarypackagepath.py'
138--- lib/lp/soyuz/model/binarypackagepath.py 2011-12-21 14:58:31 +0000
139+++ lib/lp/soyuz/model/binarypackagepath.py 1970-01-01 00:00:00 +0000
140@@ -1,37 +0,0 @@
141-# Copyright 2009 Canonical Ltd. This software is licensed under the
142-# GNU Affero General Public License version 3 (see the file LICENSE).
143-
144-__metaclass__ = type
145-
146-__all__ = [
147- 'BinaryPackagePath',
148- ]
149-
150-from storm.locals import (
151- Int,
152- RawStr,
153- Storm,
154- )
155-from zope.interface import implements
156-
157-from lp.services.database.lpstorm import IMasterStore
158-from lp.soyuz.interfaces.binarypackagepath import IBinaryPackagePath
159-
160-
161-class BinaryPackagePath(Storm):
162- """See `IBinaryPackagePath`."""
163- implements(IBinaryPackagePath)
164- __storm_table__ = 'BinaryPackagePath'
165- id = Int(primary=True)
166- path = RawStr(name='path', allow_none=False)
167-
168- def getOrCreate(self, path):
169- """See `IBinaryPackagePathSet`."""
170- store = IMasterStore(BinaryPackagePath)
171- bpp = store.find(
172- BinaryPackagePath, BinaryPackagePath.path == path).one()
173- if bpp is None:
174- bpp = BinaryPackagePath()
175- bpp.path = path
176- store.add(bpp)
177- return bpp
178
179=== removed file 'lib/lp/soyuz/model/binarypackagereleasecontents.py'
180--- lib/lp/soyuz/model/binarypackagereleasecontents.py 2011-12-21 14:58:31 +0000
181+++ lib/lp/soyuz/model/binarypackagereleasecontents.py 1970-01-01 00:00:00 +0000
182@@ -1,71 +0,0 @@
183-# Copyright 2011 Canonical Ltd. This software is licensed under the
184-# GNU Affero General Public License version 3 (see the file LICENSE).
185-
186-__metaclass__ = type
187-
188-__all__ = [
189- 'BinaryPackageReleaseContents',
190- ]
191-
192-import tempfile
193-
194-from apt.debfile import DebPackage
195-from bzrlib.osutils import pumpfile
196-from storm.locals import (
197- Int,
198- Reference,
199- Storm,
200- )
201-from zope.component import getUtility
202-from zope.interface import implements
203-
204-from lp.services.database.lpstorm import IMasterStore
205-from lp.soyuz.interfaces.binarypackagepath import IBinaryPackagePathSet
206-from lp.soyuz.interfaces.binarypackagereleasecontents import (
207- IBinaryPackageReleaseContents,
208- )
209-
210-
211-class BinaryPackageReleaseContents(Storm):
212- """See `IBinaryPackageReleaseContents`."""
213- implements(IBinaryPackageReleaseContents)
214- __storm_table__ = 'BinaryPackageReleaseContents'
215- __storm_primary__ = ("binarypackagerelease_id", "binarypackagepath_id")
216-
217- binarypackagerelease_id = Int(
218- name='binarypackagerelease', allow_none=False)
219- binarypackagerelease = Reference(
220- binarypackagerelease_id, 'BinaryPackageRelease.id')
221-
222- binarypackagepath_id = Int(name='binarypackagepath', allow_none=False)
223- binarypackagepath = Reference(
224- binarypackagepath_id, 'BinaryPackagePath.id')
225-
226- def add(self, bpr):
227- """See `IBinaryPackageReleaseContentsSet`."""
228- if not bpr.files:
229- return False
230- store = IMasterStore(BinaryPackageReleaseContents)
231- with tempfile.NamedTemporaryFile() as dest_file:
232- bpr.files[0].libraryfile.open()
233- pumpfile(bpr.files[0].libraryfile, dest_file)
234- dest_file.seek(0)
235- deb = DebPackage(filename=dest_file.name)
236- # Filter out directories.
237- filelist = filter(lambda x: not x.endswith('/'), deb.filelist)
238- for filename in filelist:
239- bpp = getUtility(IBinaryPackagePathSet).getOrCreate(
240- filename)
241- bprc = BinaryPackageReleaseContents()
242- bprc.binarypackagerelease = bpr
243- bprc.binarypackagepath = bpp
244- store.add(bprc)
245- return True
246-
247- def remove(self, bpr):
248- """See `IBinaryPackageReleaseContentsSet`."""
249- store = IMasterStore(BinaryPackageReleaseContents)
250- results = store.find(
251- BinaryPackageReleaseContents,
252- BinaryPackageReleaseContents.binarypackagerelease == bpr.id)
253- results.remove()
254
255=== removed file 'lib/lp/soyuz/tests/test_binarypackagepath.py'
256--- lib/lp/soyuz/tests/test_binarypackagepath.py 2012-01-01 02:58:52 +0000
257+++ lib/lp/soyuz/tests/test_binarypackagepath.py 1970-01-01 00:00:00 +0000
258@@ -1,26 +0,0 @@
259-# Copyright 2011 Canonical Ltd. This software is licensed under the
260-# GNU Affero General Public License version 3 (see the file LICENSE).
261-
262-"""Test the Binary Package Path model."""
263-
264-__metaclass__ = type
265-
266-from zope.component import getUtility
267-
268-from lp.soyuz.interfaces.binarypackagepath import IBinaryPackagePathSet
269-from lp.testing import TestCaseWithFactory
270-from lp.testing.layers import DatabaseFunctionalLayer
271-
272-
273-class TestBinaryPackagePath(TestCaseWithFactory):
274-
275- layer = DatabaseFunctionalLayer
276-
277- def test_getOrCreate(self):
278- bpp = getUtility(IBinaryPackagePathSet).getOrCreate('bin/bash')
279- self.assertEqual('bin/bash', bpp.path)
280-
281- def test_getOrCreate_existing(self):
282- orig_bpp = getUtility(IBinaryPackagePathSet).getOrCreate('bin/bash')
283- bpp = getUtility(IBinaryPackagePathSet).getOrCreate('bin/bash')
284- self.assertEqual(orig_bpp.id, bpp.id)
285
286=== removed file 'lib/lp/soyuz/tests/test_binarypackagereleasecontents.py'
287--- lib/lp/soyuz/tests/test_binarypackagereleasecontents.py 2012-01-01 02:58:52 +0000
288+++ lib/lp/soyuz/tests/test_binarypackagereleasecontents.py 1970-01-01 00:00:00 +0000
289@@ -1,65 +0,0 @@
290-# Copyright 2011 Canonical Ltd. This software is licensed under the
291-# GNU Affero General Public License version 3 (see the file LICENSE).
292-
293-"""Test the Binary Package Release Contents model."""
294-
295-__metaclass__ = type
296-
297-import transaction
298-from zope.component import getUtility
299-
300-from lp.archiveuploader.tests import datadir
301-from lp.services.database.lpstorm import IStore
302-from lp.soyuz.interfaces.binarypackagereleasecontents import (
303- IBinaryPackageReleaseContentsSet,
304- )
305-from lp.soyuz.model.binarypackagereleasecontents import (
306- BinaryPackageReleaseContents,
307- )
308-from lp.testing import TestCaseWithFactory
309-from lp.testing.layers import LaunchpadFunctionalLayer
310-
311-
312-class TestBinaryPackageReleaseContents(TestCaseWithFactory):
313-
314- layer = LaunchpadFunctionalLayer
315-
316- def create_bpr(self):
317- bpr = self.factory.makeBinaryPackageRelease()
318- deb = open(datadir('pmount_0.9.7-2ubuntu2_amd64.deb'), 'r')
319- lfa = self.factory.makeLibraryFileAlias(
320- filename='pmount_0.9.7-2ubuntu2_amd64.deb', content=deb.read())
321- deb.close()
322- transaction.commit()
323- bpr.addFile(lfa)
324- return bpr
325-
326- def test_add(self):
327- bpr = self.create_bpr()
328- getUtility(IBinaryPackageReleaseContentsSet).add(bpr)
329- store = IStore(BinaryPackageReleaseContents)
330- results = store.find(
331- BinaryPackageReleaseContents,
332- BinaryPackageReleaseContents.binarypackagerelease == bpr.id)
333- paths = map(lambda x: x.binarypackagepath.path, results)
334- expected_paths = [
335- 'etc/pmount.allow', 'usr/bin/pumount', 'usr/bin/pmount-hal',
336- 'usr/bin/pmount', 'usr/share/doc/pmount/TODO',
337- 'usr/share/doc/pmount/README.Debian',
338- 'usr/share/doc/pmount/AUTHORS', 'usr/share/doc/pmount/copyright',
339- 'usr/share/doc/pmount/changelog.gz',
340- 'usr/share/doc/pmount/changelog.Debian.gz',
341- 'usr/share/man/man1/pmount-hal.1.gz',
342- 'usr/share/man/man1/pmount.1.gz',
343- 'usr/share/man/man1/pumount.1.gz']
344- self.assertContentEqual(expected_paths, paths)
345-
346- def test_remove(self):
347- bpr = self.create_bpr()
348- getUtility(IBinaryPackageReleaseContentsSet).add(bpr)
349- getUtility(IBinaryPackageReleaseContentsSet).remove(bpr)
350- store = IStore(BinaryPackageReleaseContents)
351- results = store.find(
352- BinaryPackageReleaseContents,
353- BinaryPackageReleaseContents.binarypackagerelease == bpr.id)
354- self.assertEqual(0, results.count())