7
7
from zope.security.proxy import removeSecurityProxy
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,
136
138
def test_getFileByName_unhandled_name(self):
137
139
spph = self.factory.makeSourcePackagePublishingHistory()
138
140
self.assertRaises(NotFoundError, spph.getFileByName, 'not-changelog')
143
class TestBinaryPackagePublishingHistory(TestCaseWithFactory):
145
layer = LaunchpadFunctionalLayer
147
def test_binaryFileUrls_no_binaries(self):
148
bpr = self.factory.makeBinaryPackageRelease()
149
bpph = self.factory.makeBinaryPackagePublishingHistory(
150
binarypackagerelease=bpr)
152
self.assertContentEqual(expected_urls, bpph.binaryFileUrls())
154
def get_urls_for_binarypackagerelease(self, bpr, archive):
155
return [ProxiedLibraryFileAlias(f.libraryfile, archive).http_url
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())
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())