示例#1
0
 def test_getKey_returns_None_on_name_mismatch(self):
     # If extractSeriesKey returns None, getKey also returns None.
     copier = CustomUploadsCopier(FakeDistroSeries())
     copier.extractSeriesKey = FakeMethod()
     self.assertIsNone(
         copier.getKey(
             FakeUpload(PackageUploadCustomFormat.DEBIAN_INSTALLER,
                        "bad-filename.tar")))
示例#2
0
 def test_getLatestUploads_indexes_uploads_by_key(self):
     # getLatestUploads returns a dict of uploads, indexed by keys
     # returned by getKey.
     source_series = self.factory.makeDistroSeries()
     upload = self.makeUpload(source_series)
     copier = CustomUploadsCopier(FakeDistroSeries())
     self.assertEqual({copier.getKey(upload): upload},
                      copier.getLatestUploads(source_series))
 def test_getKey_returns_None_on_name_mismatch(self):
     # If extractSeriesKey returns None, getKey also returns None.
     copier = CustomUploadsCopier(FakeDistroSeries())
     copier.extractSeriesKey = FakeMethod()
     self.assertIsNone(
         copier.getKey(FakeUpload(
             PackageUploadCustomFormat.DEBIAN_INSTALLER,
             "bad-filename.tar")))
 def test_getLatestUploads_indexes_uploads_by_key(self):
     # getLatestUploads returns a dict of uploads, indexed by keys
     # returned by getKey.
     source_series = self.factory.makeDistroSeries()
     upload = self.makeUpload(source_series)
     copier = CustomUploadsCopier(FakeDistroSeries())
     self.assertEqual(
         {copier.getKey(upload): upload},
         copier.getLatestUploads(source_series))
 def test_getKey_ddtp_includes_format_and_component(self):
     # The key returned by getKey for a ddtp-tarball upload consists of
     # custom upload type, and component.
     source_series = self.factory.makeDistroSeries()
     upload = self.makeUpload(
         source_series, custom_type=PackageUploadCustomFormat.DDTP_TARBALL,
         component='restricted')
     copier = CustomUploadsCopier(FakeDistroSeries())
     expected_key = (PackageUploadCustomFormat.DDTP_TARBALL, 'restricted')
     self.assertEqual(expected_key, copier.getKey(upload))
 def test_getKey_includes_format_and_architecture(self):
     # The key returned by getKey consists of custom upload type,
     # and architecture.
     source_series = self.factory.makeDistroSeries()
     upload = self.makeUpload(
         source_series, custom_type=PackageUploadCustomFormat.DIST_UPGRADER,
         arch='mips')
     copier = CustomUploadsCopier(FakeDistroSeries())
     expected_key = (PackageUploadCustomFormat.DIST_UPGRADER, 'mips')
     self.assertEqual(expected_key, copier.getKey(upload))
示例#7
0
 def test_getKey_ddtp_includes_format_and_component(self):
     # The key returned by getKey for a ddtp-tarball upload consists of
     # custom upload type, and component.
     source_series = self.factory.makeDistroSeries()
     upload = self.makeUpload(
         source_series,
         custom_type=PackageUploadCustomFormat.DDTP_TARBALL,
         component='restricted')
     copier = CustomUploadsCopier(FakeDistroSeries())
     expected_key = (PackageUploadCustomFormat.DDTP_TARBALL, 'restricted')
     self.assertEqual(expected_key, copier.getKey(upload))
示例#8
0
 def test_getKey_includes_format_and_architecture(self):
     # The key returned by getKey consists of custom upload type,
     # and architecture.
     source_series = self.factory.makeDistroSeries()
     upload = self.makeUpload(
         source_series,
         custom_type=PackageUploadCustomFormat.DIST_UPGRADER,
         arch='mips')
     copier = CustomUploadsCopier(FakeDistroSeries())
     expected_key = (PackageUploadCustomFormat.DIST_UPGRADER, 'mips')
     self.assertEqual(expected_key, copier.getKey(upload))
示例#9
0
    def test_getKey_calls_correct_custom_upload_method(self):
        # getKey calls the getSeriesKey method on the correct custom upload.
        class FakeCustomUpload:
            @classmethod
            def getSeriesKey(cls, tarfile_path):
                return "dummy"

        copier = CustomUploadsCopier(FakeDistroSeries())
        copier.copyable_types = {
            PackageUploadCustomFormat.DEBIAN_INSTALLER: FakeCustomUpload,
        }
        custom_format, series_key = copier.getKey(
            FakeUpload(PackageUploadCustomFormat.DEBIAN_INSTALLER, "anything"))
        self.assertEqual(PackageUploadCustomFormat.DEBIAN_INSTALLER,
                         custom_format)
        self.assertEqual("dummy", series_key)
    def test_getKey_calls_correct_custom_upload_method(self):
        # getKey calls the getSeriesKey method on the correct custom upload.
        class FakeCustomUpload:
            @classmethod
            def getSeriesKey(cls, tarfile_path):
                return "dummy"

        copier = CustomUploadsCopier(FakeDistroSeries())
        copier.copyable_types = {
            PackageUploadCustomFormat.DEBIAN_INSTALLER: FakeCustomUpload,
            }
        custom_format, series_key = copier.getKey(
            FakeUpload(PackageUploadCustomFormat.DEBIAN_INSTALLER, "anything"))
        self.assertEqual(
            PackageUploadCustomFormat.DEBIAN_INSTALLER, custom_format)
        self.assertEqual("dummy", series_key)