def test_copy_asynchronously_handles_no_dest_series(self):
     # If dest_series is None, copy_asynchronously creates jobs that will
     # copy each source into the same distroseries in the target archive.
     distribution = self.makeDistribution()
     series_one = self.factory.makeDistroSeries(
         distribution=distribution, registrant=self.person)
     series_two = self.factory.makeDistroSeries(
         distribution=distribution, registrant=self.person)
     spph_one = self.factory.makeSourcePackagePublishingHistory(
         distroseries=series_one, sourcepackagename="one",
         maintainer=self.person, creator=self.person)
     spph_two = self.factory.makeSourcePackagePublishingHistory(
         distroseries=series_two, sourcepackagename="two",
         maintainer=self.person, creator=self.person)
     pocket = self.factory.getAnyPocket()
     target_archive = self.factory.makeArchive(
         owner=self.person, distribution=distribution)
     copy_asynchronously(
         [spph_one, spph_two], target_archive, None, pocket,
         include_binaries=False, check_permissions=False,
         person=self.person)
     jobs = list(getUtility(IPlainPackageCopyJobSource).getActiveJobs(
         target_archive))
     self.assertEqual(2, len(jobs))
     self.assertContentEqual(
         [("one", spph_one.distroseries), ("two", spph_two.distroseries)],
         [(job.package_name, job.target_distroseries) for job in jobs])
 def test_copy_asynchronously_does_not_copy_packages(self):
     # copy_asynchronously does not copy packages into the destination
     # archive; that happens later, asynchronously.
     spph = self.makeSPPH()
     dest_series = self.makeDerivedSeries()
     archive = dest_series.distribution.main_archive
     pocket = self.factory.getAnyPocket()
     copy_asynchronously(
         [spph], archive, dest_series, pocket, include_binaries=False,
         check_permissions=False, person=self.factory.makePerson())
     self.assertEqual(None, find_spph_copy(archive, spph))
 def test_copy_asynchronously_does_not_copy_packages(self):
     # copy_asynchronously does not copy packages into the destination
     # archive; that happens later, asynchronously.
     spph = self.makeSPPH()
     dest_series = self.makeDerivedSeries()
     archive = dest_series.distribution.main_archive
     pocket = self.factory.getAnyPocket()
     copy_asynchronously([spph],
                         archive,
                         dest_series,
                         pocket,
                         include_binaries=False,
                         check_permissions=False,
                         person=self.factory.makePerson())
     self.assertEqual(None, find_spph_copy(archive, spph))
 def test_copy_asynchronously_creates_copy_jobs(self):
     # copy_asynchronously creates PackageCopyJobs.
     spph = self.makeSPPH()
     dest_series = self.makeDerivedSeries()
     pocket = self.factory.getAnyPocket()
     archive = dest_series.distribution.main_archive
     copy_asynchronously(
         [spph], archive, dest_series, pocket, include_binaries=False,
         check_permissions=False, person=self.factory.makePerson())
     jobs = list(getUtility(IPlainPackageCopyJobSource).getActiveJobs(
         archive))
     self.assertEqual(1, len(jobs))
     job = jobs[0]
     spr = spph.sourcepackagerelease
     self.assertEqual(spr.sourcepackagename.name, job.package_name)
     self.assertEqual(spr.version, job.package_version)
     self.assertEqual(dest_series, job.target_distroseries)
 def test_copy_asynchronously_creates_copy_jobs(self):
     # copy_asynchronously creates PackageCopyJobs.
     spph = self.makeSPPH()
     dest_series = self.makeDerivedSeries()
     pocket = self.factory.getAnyPocket()
     archive = dest_series.distribution.main_archive
     copy_asynchronously([spph],
                         archive,
                         dest_series,
                         pocket,
                         include_binaries=False,
                         check_permissions=False,
                         person=self.factory.makePerson())
     jobs = list(
         getUtility(IPlainPackageCopyJobSource).getActiveJobs(archive))
     self.assertEqual(1, len(jobs))
     job = jobs[0]
     spr = spph.sourcepackagerelease
     self.assertEqual(spr.sourcepackagename.name, job.package_name)
     self.assertEqual(spr.version, job.package_version)
     self.assertEqual(dest_series, job.target_distroseries)
 def test_copy_asynchronously_may_allow_copy(self):
     # In a normal working situation, copy_asynchronously allows a
     # copy.
     spph = self.makeSPPH()
     pocket = PackagePublishingPocket.RELEASE
     dest_series = self.makeDerivedSeries()
     dest_archive = dest_series.main_archive
     spn = spph.sourcepackagerelease.sourcepackagename
     notification = copy_asynchronously(
         [spph], dest_archive, dest_series, pocket, False,
         person=self.getUploader(dest_archive, spn))
     self.assertIn("Requested", notification.escapedtext)
 def test_copy_asynchronously_handles_no_dest_series(self):
     # If dest_series is None, copy_asynchronously creates jobs that will
     # copy each source into the same distroseries in the target archive.
     distribution = self.makeDistribution()
     series_one = self.factory.makeDistroSeries(distribution=distribution,
                                                registrant=self.person)
     series_two = self.factory.makeDistroSeries(distribution=distribution,
                                                registrant=self.person)
     spph_one = self.factory.makeSourcePackagePublishingHistory(
         distroseries=series_one,
         sourcepackagename="one",
         maintainer=self.person,
         creator=self.person)
     spph_two = self.factory.makeSourcePackagePublishingHistory(
         distroseries=series_two,
         sourcepackagename="two",
         maintainer=self.person,
         creator=self.person)
     pocket = self.factory.getAnyPocket()
     target_archive = self.factory.makeArchive(owner=self.person,
                                               distribution=distribution)
     copy_asynchronously([spph_one, spph_two],
                         target_archive,
                         None,
                         pocket,
                         include_binaries=False,
                         check_permissions=False,
                         person=self.person)
     jobs = list(
         getUtility(IPlainPackageCopyJobSource).getActiveJobs(
             target_archive))
     self.assertEqual(2, len(jobs))
     self.assertContentEqual([("one", spph_one.distroseries),
                              ("two", spph_two.distroseries)],
                             [(job.package_name, job.target_distroseries)
                              for job in jobs])
 def test_copy_asynchronously_may_allow_copy(self):
     # In a normal working situation, copy_asynchronously allows a
     # copy.
     spph = self.makeSPPH()
     pocket = PackagePublishingPocket.RELEASE
     dest_series = self.makeDerivedSeries()
     dest_archive = dest_series.main_archive
     spn = spph.sourcepackagerelease.sourcepackagename
     notification = copy_asynchronously([spph],
                                        dest_archive,
                                        dest_series,
                                        pocket,
                                        False,
                                        person=self.getUploader(
                                            dest_archive, spn))
     self.assertIn("Requested", notification.escapedtext)