コード例 #1
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())
コード例 #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_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())
コード例 #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_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)
コード例 #7
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)
コード例 #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()
コード例 #14
0
    def distributionsourcepackage(self):
        """See IDistributionSourcePackageCache."""

        # import here to avoid circular imports
        from lp.registry.model.distributionsourcepackage import (
            DistributionSourcePackage)

        return DistributionSourcePackage(self.distribution,
                                         self.sourcepackagename)
コード例 #15
0
 def translation_target(self):
     """See `ICustomLanguageCode`."""
     # Avoid circular imports
     from lp.registry.model.distributionsourcepackage import (
         DistributionSourcePackage)
     if self.product:
         return self.product
     else:
         return DistributionSourcePackage(self.distribution,
                                          self.sourcepackagename)
コード例 #16
0
 def test_unsetBranch_delete_unpublished_dsp(self):
     # Setting the official branch for a pocket to 'None' deletes the
     # official DSP record if there is no SPPH.
     sourcepackage = self.factory.makeSourcePackage()
     pocket = PackagePublishingPocket.RELEASE
     registrant = self.factory.makePerson()
     branch = self.factory.makePackageBranch(sourcepackage=sourcepackage)
     with person_logged_in(sourcepackage.distribution.owner):
         sourcepackage.setBranch(pocket, branch, registrant)
         sourcepackage.setBranch(pocket, None, registrant)
     new_dsp = DistributionSourcePackage._get(
         sourcepackage.distribution, sourcepackage.sourcepackagename)
     self.assertIs(None, new_dsp)
コード例 #17
0
 def test_setBranch(self):
     # We can set the official branch for a pocket of a source package.
     sourcepackage = self.factory.makeSourcePackage()
     pocket = PackagePublishingPocket.RELEASE
     registrant = self.factory.makePerson()
     branch = self.factory.makePackageBranch(sourcepackage=sourcepackage)
     with person_logged_in(sourcepackage.distribution.owner):
         sourcepackage.setBranch(pocket, branch, registrant)
     self.assertEqual(branch, sourcepackage.getBranch(pocket))
     # A DSP was created for the official branch.
     new_dsp = DistributionSourcePackage._get(
         sourcepackage.distribution, sourcepackage.sourcepackagename)
     self.assertIsNot(None, new_dsp)
コード例 #18
0
 def test_unsetBranch_delete_unpublished_dsp(self):
     # Setting the official branch for a pocket to 'None' deletes the
     # official DSP record if there is no SPPH.
     sourcepackage = self.factory.makeSourcePackage()
     pocket = PackagePublishingPocket.RELEASE
     registrant = self.factory.makePerson()
     branch = self.factory.makePackageBranch(sourcepackage=sourcepackage)
     with person_logged_in(sourcepackage.distribution.owner):
         sourcepackage.setBranch(pocket, branch, registrant)
         sourcepackage.setBranch(pocket, None, registrant)
     new_dsp = DistributionSourcePackage._get(
         sourcepackage.distribution, sourcepackage.sourcepackagename)
     self.assertIs(None, new_dsp)
コード例 #19
0
 def test_setBranch(self):
     # We can set the official branch for a pocket of a source package.
     sourcepackage = self.factory.makeSourcePackage()
     pocket = PackagePublishingPocket.RELEASE
     registrant = self.factory.makePerson()
     branch = self.factory.makePackageBranch(sourcepackage=sourcepackage)
     with person_logged_in(sourcepackage.distribution.owner):
         sourcepackage.setBranch(pocket, branch, registrant)
     self.assertEqual(branch, sourcepackage.getBranch(pocket))
     # A DSP was created for the official branch.
     new_dsp = DistributionSourcePackage._get(
         sourcepackage.distribution, sourcepackage.sourcepackagename)
     self.assertIsNot(None, new_dsp)
コード例 #20
0
 def target(self):
     """See `IStructuralSubscription`."""
     if self.product is not None:
         return self.product
     elif self.productseries is not None:
         return self.productseries
     elif self.project is not None:
         return self.project
     elif self.milestone is not None:
         return self.milestone
     elif self.distribution is not None:
         if self.sourcepackagename is not None:
             # Circular imports.
             from lp.registry.model.distributionsourcepackage import (
                 DistributionSourcePackage)
             return DistributionSourcePackage(
                 self.distribution, self.sourcepackagename)
         else:
             return self.distribution
     elif self.distroseries is not None:
         return self.distroseries
     else:
         raise AssertionError('StructuralSubscription has no target.')