Example #1
0
 def makeScript(self, distro=None, extra_args=[]):
     """Produce instance of the `PublishFTPMaster` script."""
     if distro is None:
         distro = self.makeDistroWithPublishDirectory()
     script = PublishFTPMaster(test_args=["-d", distro.name] + extra_args)
     script.txn = self.layer.txn
     script.logger = DevNullLogger()
     return script
 def makeScript(self, distro=None, extra_args=[]):
     """Produce instance of the `PublishFTPMaster` script."""
     if distro is None:
         distro = self.makeDistroWithPublishDirectory()
     script = PublishFTPMaster(test_args=["-d", distro.name] + extra_args)
     script.txn = self.layer.txn
     script.logger = DevNullLogger()
     return script
 def test_main(self):
     # If run end-to-end, the script generates Contents.gz files, and a
     # following publisher run will put those files in their final place
     # and include them in the Release file.
     distro = self.makeDistro()
     distroseries = self.factory.makeDistroSeries(distribution=distro)
     processor = self.factory.makeProcessor()
     das = self.factory.makeDistroArchSeries(distroseries=distroseries,
                                             processor=processor)
     package = self.factory.makeSuiteSourcePackage(distroseries)
     self.factory.makeSourcePackagePublishingHistory(
         distroseries=distroseries, pocket=package.pocket)
     self.factory.makeBinaryPackageBuild(distroarchseries=das,
                                         pocket=package.pocket,
                                         processor=processor)
     suite = package.suite
     script = self.makeScript(distro)
     os.makedirs(os.path.join(script.config.distsroot, package.suite))
     self.assertNotEqual([], list(script.getSuites()))
     fake_overrides(script, distroseries)
     script.process()
     self.assertTrue(
         file_exists(
             os.path.join(script.config.stagingroot, suite,
                          "Contents-%s.gz" % das.architecturetag)))
     publisher_script = PublishFTPMaster(test_args=["-d", distro.name])
     publisher_script.txn = self.layer.txn
     publisher_script.logger = DevNullLogger()
     publisher_script.main()
     contents_path = os.path.join(script.config.distsroot, suite,
                                  "Contents-%s.gz" % das.architecturetag)
     self.assertTrue(file_exists(contents_path))
     with open(contents_path, "rb") as contents_file:
         contents_bytes = contents_file.read()
     release_path = os.path.join(script.config.distsroot, suite, "Release")
     self.assertTrue(file_exists(release_path))
     with open(release_path) as release_file:
         release_lines = release_file.readlines()
     self.assertIn(
         " %s %16s Contents-%s.gz\n" %
         (hashlib.md5(contents_bytes).hexdigest(), len(contents_bytes),
          das.architecturetag), release_lines)