~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/tests/test_publishing.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-26 14:57:54 UTC
  • mfrom: (13794.1.12 bug-832661)
  • Revision ID: launchpad@pqm.canonical.com-20110826145754-364nkd1s6ofz4nqd
[r=adeuring][bug=832661] Create DSDJs from requestDeletion.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
from lp.registry.interfaces.pocket import PackagePublishingPocket
38
38
from lp.registry.interfaces.sourcepackage import SourcePackageUrgency
39
39
from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet
 
40
from lp.services.features.testing import FeatureFixture
40
41
from lp.services.log.logger import DevNullLogger
41
42
from lp.soyuz.adapters.overrides import UnknownOverridePolicy
42
43
from lp.soyuz.enums import (
55
56
    )
56
57
from lp.soyuz.interfaces.queue import QueueInconsistentStateError
57
58
from lp.soyuz.interfaces.section import ISectionSet
 
59
from lp.soyuz.model.distroseriesdifferencejob import (
 
60
    FEATURE_FLAG_ENABLE_MODULE,
 
61
    find_waiting_jobs,
 
62
    )
58
63
from lp.soyuz.model.distroseriespackagecache import DistroSeriesPackageCache
59
64
from lp.soyuz.model.processor import ProcessorFamily
60
65
from lp.soyuz.model.publishing import (
1167
1172
 
1168
1173
    layer = ZopelessDatabaseLayer
1169
1174
 
1170
 
    def makeMatchingSourceAndBinaryPPH(self):
1171
 
        """Produce a matching pair of SPPH and BPPH.
1172
 
 
1173
 
        Returns a tuple of one SourcePackagePublishingHistory "spph" and
1174
 
        one BinaryPackagePublishingHistory "bpph" stemming from the same
1175
 
        source package, published into the same distroseries, pocket, and
1176
 
        archive.
1177
 
        """
1178
 
        bpph = self.factory.makeBinaryPackagePublishingHistory()
1179
 
        bpr = bpph.binarypackagerelease
1180
 
        self.assertNotEqual(None, bpr)
1181
 
        spph = self.factory.makeSourcePackagePublishingHistory(
1182
 
            distroseries=bpph.distroarchseries.distroseries,
1183
 
            sourcepackagerelease=bpr.build.source_package_release,
1184
 
            pocket=bpph.pocket, archive=bpph.archive)
1185
 
        return spph, bpph
1186
 
 
1187
 
    def test_makeMatchingSourceAndBinaryPPH(self):
1188
 
        # makeMatchingSourceAndBinaryPPH really produces a matching pair
1189
 
        # of spph and bpph.
1190
 
        spph, bpph = self.makeMatchingSourceAndBinaryPPH()
1191
 
        self.assertContentEqual([bpph], spph.getPublishedBinaries())
 
1175
    def enableDistroDerivation(self):
 
1176
        self.useFixture(FeatureFixture({FEATURE_FLAG_ENABLE_MODULE: u'on'}))
1192
1177
 
1193
1178
    def test_requestDeletion_marks_SPPHs_deleted(self):
1194
1179
        spph = self.factory.makeSourcePackagePublishingHistory()
1195
1180
        getUtility(IPublishingSet).requestDeletion(
1196
1181
            [spph], self.factory.makePerson())
 
1182
        # XXX JeroenVermeulen 2011-08-25, bug=834388: obviate commit.
1197
1183
        transaction.commit()
1198
1184
        self.assertEqual(PackagePublishingStatus.DELETED, spph.status)
1199
1185
 
1202
1188
        other_spph = self.factory.makeSourcePackagePublishingHistory()
1203
1189
        getUtility(IPublishingSet).requestDeletion(
1204
1190
            [other_spph], self.factory.makePerson())
 
1191
        # XXX JeroenVermeulen 2011-08-25, bug=834388: obviate commit.
1205
1192
        transaction.commit()
1206
1193
        self.assertEqual(PackagePublishingStatus.PENDING, spph.status)
1207
1194
 
1208
1195
    def test_requestDeletion_marks_attached_BPPHs_deleted(self):
1209
 
        spph, bpph = self.makeMatchingSourceAndBinaryPPH()
 
1196
        bpph = self.factory.makeBinaryPackagePublishingHistory()
 
1197
        spph = self.factory.makeSPPHForBPPH(bpph)
1210
1198
        getUtility(IPublishingSet).requestDeletion(
1211
1199
            [spph], self.factory.makePerson())
 
1200
        # XXX JeroenVermeulen 2011-08-25, bug=834388: obviate commit.
1212
1201
        transaction.commit()
1213
1202
        self.assertEqual(PackagePublishingStatus.DELETED, spph.status)
1214
1203
 
1217
1206
        unrelated_spph = self.factory.makeSourcePackagePublishingHistory()
1218
1207
        getUtility(IPublishingSet).requestDeletion(
1219
1208
            [unrelated_spph], self.factory.makePerson())
 
1209
        # XXX JeroenVermeulen 2011-08-25, bug=834388: obviate commit.
1220
1210
        transaction.commit()
1221
1211
        self.assertEqual(PackagePublishingStatus.PENDING, bpph.status)
1222
1212
 
1226
1216
        # The test is that this does not fail.
1227
1217
        Store.of(person).flush()
1228
1218
 
 
1219
    def test_requestDeletion_creates_DistroSeriesDifferenceJobs(self):
 
1220
        dsp = self.factory.makeDistroSeriesParent()
 
1221
        series = dsp.derived_series
 
1222
        spph = self.factory.makeSourcePackagePublishingHistory(
 
1223
            series, pocket=PackagePublishingPocket.RELEASE)
 
1224
        spn = spph.sourcepackagerelease.sourcepackagename
 
1225
 
 
1226
        self.enableDistroDerivation()
 
1227
        getUtility(IPublishingSet).requestDeletion(
 
1228
            [spph], self.factory.makePerson())
 
1229
 
 
1230
        self.assertEqual(
 
1231
            1, len(find_waiting_jobs(
 
1232
                dsp.derived_series, spn, dsp.parent_series)))
 
1233
 
1229
1234
 
1230
1235
class TestSourceDomination(TestNativePublishingBase):
1231
1236
    """Test SourcePackagePublishingHistory.supersede() operates correctly."""