~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/tests/test_publishing_models.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-12-21 20:45:39 UTC
  • mfrom: (14560.1.5 devel)
  • Revision ID: launchpad@pqm.canonical.com-20111221204539-1r1290npnex0ig2j
[r=jml, julian-edwards][bug=881509] Add binaryFileUrls to BPPH on the
        webservice, like it is available for SPPH.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
from zope.security.proxy import removeSecurityProxy
8
8
 
9
9
from canonical.database.constants import UTC_NOW
 
10
from canonical.launchpad.browser.librarian import ProxiedLibraryFileAlias
10
11
from canonical.launchpad.webapp.publisher import canonical_url
11
12
from canonical.testing.layers import (
12
13
    LaunchpadFunctionalLayer,
18
19
    IPublishingSet,
19
20
    PackagePublishingStatus,
20
21
    )
 
22
from lp.soyuz.enums import BinaryPackageFileType
21
23
from lp.soyuz.tests.test_binarypackagebuild import BaseTestCaseWithThreeBuilds
22
24
from lp.testing import TestCaseWithFactory
23
25
 
136
138
    def test_getFileByName_unhandled_name(self):
137
139
        spph = self.factory.makeSourcePackagePublishingHistory()
138
140
        self.assertRaises(NotFoundError, spph.getFileByName, 'not-changelog')
 
141
 
 
142
 
 
143
class TestBinaryPackagePublishingHistory(TestCaseWithFactory):
 
144
 
 
145
    layer = LaunchpadFunctionalLayer
 
146
 
 
147
    def test_binaryFileUrls_no_binaries(self):
 
148
        bpr = self.factory.makeBinaryPackageRelease()
 
149
        bpph = self.factory.makeBinaryPackagePublishingHistory(
 
150
            binarypackagerelease=bpr)
 
151
        expected_urls = []
 
152
        self.assertContentEqual(expected_urls, bpph.binaryFileUrls())
 
153
 
 
154
    def get_urls_for_binarypackagerelease(self, bpr, archive):
 
155
        return [ProxiedLibraryFileAlias(f.libraryfile, archive).http_url
 
156
            for f in bpr.files]
 
157
 
 
158
    def test_binaryFileUrls_one_binary(self):
 
159
        archive = self.factory.makeArchive(private=False)
 
160
        bpr = self.factory.makeBinaryPackageRelease()
 
161
        self.factory.makeBinaryPackageFile(binarypackagerelease=bpr)
 
162
        bpph = self.factory.makeBinaryPackagePublishingHistory(
 
163
            binarypackagerelease=bpr, archive=archive)
 
164
        expected_urls = self.get_urls_for_binarypackagerelease(bpr, archive)
 
165
        self.assertContentEqual(expected_urls, bpph.binaryFileUrls())
 
166
 
 
167
    def test_binaryFileUrls_two_binaries(self):
 
168
        archive = self.factory.makeArchive(private=False)
 
169
        bpr = self.factory.makeBinaryPackageRelease()
 
170
        self.factory.makeBinaryPackageFile(
 
171
            binarypackagerelease=bpr, filetype=BinaryPackageFileType.DEB)
 
172
        self.factory.makeBinaryPackageFile(
 
173
            binarypackagerelease=bpr, filetype=BinaryPackageFileType.DDEB)
 
174
        bpph = self.factory.makeBinaryPackagePublishingHistory(
 
175
            binarypackagerelease=bpr, archive=archive)
 
176
        expected_urls = self.get_urls_for_binarypackagerelease(bpr, archive)
 
177
        self.assertContentEqual(expected_urls, bpph.binaryFileUrls())