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)
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)
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)
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)
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)
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)
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)
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)