コード例 #1
0
 def test_delete_with_dsp_in_db_without_history(self):
     # Calling delete() on a persistent DSP without SPPH returns True.
     # A package without history was a mistake.
     sp = self.factory.makeSourcePackage()
     DistributionSourcePackage.ensure(sourcepackage=sp)
     transaction.commit()
     dsp = sp.distribution_sourcepackage
     self.assertTrue(dsp.delete())
コード例 #2
0
 def test_delete_with_dsp_in_db_without_history(self):
     # Calling delete() on a persistent DSP without SPPH returns True.
     # A package without history was a mistake.
     sp = self.factory.makeSourcePackage()
     DistributionSourcePackage.ensure(sourcepackage=sp)
     transaction.commit()
     dsp = sp.distribution_sourcepackage
     self.assertTrue(dsp.delete())
コード例 #3
0
 def test_delete_with_dsp_in_db_with_history(self):
     # Calling delete() on a persistent DSP with SPPH returns False.
     # Once a package is uploaded, it cannot be deleted.
     spph = self.factory.makeSourcePackagePublishingHistory()
     dsp = spph.sourcepackagerelease.distrosourcepackage
     DistributionSourcePackage.ensure(spph=spph)
     transaction.commit()
     self.assertFalse(dsp.delete())
コード例 #4
0
 def test_delete_with_dsp_in_db_with_history(self):
     # Calling delete() on a persistent DSP with SPPH returns False.
     # Once a package is uploaded, it cannot be deleted.
     spph = self.factory.makeSourcePackagePublishingHistory()
     dsp = spph.sourcepackagerelease.distrosourcepackage
     DistributionSourcePackage.ensure(spph=spph)
     transaction.commit()
     self.assertFalse(dsp.delete())
コード例 #5
0
 def test_ensure_spph_does_not_create_dsp_in_db_non_primary_archive(self):
     # The DSP.ensure() class method creates a persistent instance
     # if one does not exist.
     archive = self.factory.makeArchive()
     spph = self.factory.makeSourcePackagePublishingHistory(archive=archive)
     spph_dsp = spph.sourcepackagerelease.distrosourcepackage
     DistributionSourcePackage.ensure(spph)
     new_dsp = DistributionSourcePackage._get(spph_dsp.distribution,
                                              spph_dsp.sourcepackagename)
     self.assertIs(None, new_dsp)
コード例 #6
0
 def test_ensure_spph_dsp_in_db_exists(self):
     # The DSP.ensure() class method does not create duplicate
     # persistent instances; it skips the query to create the DSP.
     store = IStore(DistributionSourcePackageInDatabase)
     start_count = store.find(DistributionSourcePackageInDatabase).count()
     spph = self.factory.makeSourcePackagePublishingHistory()
     DistributionSourcePackage.ensure(spph)
     new_count = store.find(DistributionSourcePackageInDatabase).count()
     self.assertEqual(start_count + 1, new_count)
     final_count = store.find(DistributionSourcePackageInDatabase).count()
     self.assertEqual(new_count, final_count)
コード例 #7
0
 def test_ensure_suitesourcepackage_creates_a_dsp_in_db(self):
     # The DSP.ensure() class method creates a persistent instance
     # if one does not exist.
     sourcepackage = self.factory.makeSourcePackage()
     DistributionSourcePackage.ensure(sourcepackage=sourcepackage)
     new_dsp = DistributionSourcePackage._get(
         sourcepackage.distribution, sourcepackage.sourcepackagename)
     self.assertIsNot(None, new_dsp)
     self.assertEqual(sourcepackage.distribution, new_dsp.distribution)
     self.assertEqual(sourcepackage.sourcepackagename,
                      new_dsp.sourcepackagename)
コード例 #8
0
 def test_ensure_spph_does_not_create_dsp_in_db_non_primary_archive(self):
     # The DSP.ensure() class method creates a persistent instance
     # if one does not exist.
     archive = self.factory.makeArchive()
     spph = self.factory.makeSourcePackagePublishingHistory(
         archive=archive)
     spph_dsp = spph.sourcepackagerelease.distrosourcepackage
     DistributionSourcePackage.ensure(spph)
     new_dsp = DistributionSourcePackage._get(
         spph_dsp.distribution, spph_dsp.sourcepackagename)
     self.assertIs(None, new_dsp)
コード例 #9
0
 def test_ensure_spph_dsp_in_db_exists(self):
     # The DSP.ensure() class method does not create duplicate
     # persistent instances; it skips the query to create the DSP.
     store = IStore(DistributionSourcePackageInDatabase)
     start_count = store.find(DistributionSourcePackageInDatabase).count()
     spph = self.factory.makeSourcePackagePublishingHistory()
     DistributionSourcePackage.ensure(spph)
     new_count = store.find(DistributionSourcePackageInDatabase).count()
     self.assertEqual(start_count + 1, new_count)
     final_count = store.find(DistributionSourcePackageInDatabase).count()
     self.assertEqual(new_count, final_count)
コード例 #10
0
 def test_ensure_suitesourcepackage_creates_a_dsp_in_db(self):
     # The DSP.ensure() class method creates a persistent instance
     # if one does not exist.
     sourcepackage = self.factory.makeSourcePackage()
     DistributionSourcePackage.ensure(sourcepackage=sourcepackage)
     new_dsp = DistributionSourcePackage._get(
         sourcepackage.distribution, sourcepackage.sourcepackagename)
     self.assertIsNot(None, new_dsp)
     self.assertEqual(sourcepackage.distribution, new_dsp.distribution)
     self.assertEqual(
         sourcepackage.sourcepackagename, new_dsp.sourcepackagename)
コード例 #11
0
 def test_ensure_spph_creates_a_dsp_in_db(self):
     # The DSP.ensure() class method creates a persistent instance
     # if one does not exist.
     spph = self.factory.makeSourcePackagePublishingHistory()
     spph_dsp = spph.sourcepackagerelease.distrosourcepackage
     DistributionSourcePackage.ensure(spph)
     new_dsp = DistributionSourcePackage._get(spph_dsp.distribution,
                                              spph_dsp.sourcepackagename)
     self.assertIsNot(None, new_dsp)
     self.assertIsNot(spph_dsp, new_dsp)
     self.assertEqual(spph_dsp.distribution, new_dsp.distribution)
     self.assertEqual(spph_dsp.sourcepackagename, new_dsp.sourcepackagename)
コード例 #12
0
 def test_ensure_spph_creates_a_dsp_in_db(self):
     # The DSP.ensure() class method creates a persistent instance
     # if one does not exist.
     spph = self.factory.makeSourcePackagePublishingHistory()
     spph_dsp = spph.sourcepackagerelease.distrosourcepackage
     DistributionSourcePackage.ensure(spph)
     new_dsp = DistributionSourcePackage._get(
         spph_dsp.distribution, spph_dsp.sourcepackagename)
     self.assertIsNot(None, new_dsp)
     self.assertIsNot(spph_dsp, new_dsp)
     self.assertEqual(spph_dsp.distribution, new_dsp.distribution)
     self.assertEqual(
         spph_dsp.sourcepackagename, new_dsp.sourcepackagename)
コード例 #13
0
 def setBranch(self, pocket, branch, registrant):
     """See `ISourcePackage`."""
     SeriesSourcePackageBranchSet.delete(self, pocket)
     if branch is not None:
         SeriesSourcePackageBranchSet.new(self.distroseries, pocket,
                                          self.sourcepackagename, branch,
                                          registrant)
         # Avoid circular imports.
         from lp.registry.model.distributionsourcepackage import (
             DistributionSourcePackage, )
         DistributionSourcePackage.ensure(sourcepackage=self)
     else:
         # Delete the official DSP if there is no publishing history.
         self.distribution_sourcepackage.delete()