323
326
find_waiting_jobs(dsp.derived_series, package, dsp.parent_series))
328
def test_createForSPPHs_creates_job_for_derived_series(self):
329
dsp = self.factory.makeDistroSeriesParent()
330
spph = self.factory.makeSourcePackagePublishingHistory(
331
dsp.parent_series, pocket=PackagePublishingPocket.RELEASE)
332
spn = spph.sourcepackagerelease.sourcepackagename
334
self.getJobSource().createForSPPHs([spph])
337
1, len(find_waiting_jobs(
338
dsp.derived_series, spn, dsp.parent_series)))
340
def test_createForSPPHs_creates_job_for_parent_series(self):
341
dsp = self.factory.makeDistroSeriesParent()
342
spph = self.factory.makeSourcePackagePublishingHistory(
343
dsp.derived_series, pocket=PackagePublishingPocket.RELEASE)
344
spn = spph.sourcepackagerelease.sourcepackagename
346
self.getJobSource().createForSPPHs([spph])
349
1, len(find_waiting_jobs(
350
dsp.derived_series, spn, dsp.parent_series)))
352
def test_createForSPPHs_obeys_feature_flag(self):
353
self.useFixture(FeatureFixture({FEATURE_FLAG_ENABLE_MODULE: ''}))
354
dsp = self.factory.makeDistroSeriesParent()
355
spph = self.factory.makeSourcePackagePublishingHistory(
356
dsp.parent_series, pocket=PackagePublishingPocket.RELEASE)
357
spn = spph.sourcepackagerelease.sourcepackagename
358
self.getJobSource().createForSPPHs([spph])
359
self.assertContentEqual(
360
[], find_waiting_jobs(dsp.derived_series, spn, dsp.parent_series))
362
def test_createForSPPHs_ignores_backports_and_proposed(self):
363
dsp = self.factory.makeDistroSeriesParent()
364
spr = self.factory.makeSourcePackageRelease()
365
spn = spr.sourcepackagename
367
PackagePublishingPocket.BACKPORTS,
368
PackagePublishingPocket.PROPOSED,
371
self.factory.makeSourcePackagePublishingHistory(
372
distroseries=dsp.parent_series, sourcepackagerelease=spr,
374
for pocket in ignored_pockets]
375
self.getJobSource().createForSPPHs(spphs)
376
self.assertContentEqual(
377
[], find_waiting_jobs(dsp.derived_series, spn, dsp.parent_series))
379
def test_createForSPPHs_creates_no_jobs_for_unrelated_series(self):
380
dsp = self.factory.makeDistroSeriesParent()
381
other_series = self.factory.makeDistroSeries(
382
distribution=dsp.derived_series.distribution)
383
spph = self.factory.makeSourcePackagePublishingHistory(
384
dsp.parent_series, pocket=PackagePublishingPocket.RELEASE)
385
spn = spph.sourcepackagerelease.sourcepackagename
386
self.getJobSource().createForSPPHs([spph])
387
self.assertContentEqual(
388
[], find_waiting_jobs(dsp.derived_series, spn, other_series))
390
def test_createForSPPHs_accepts_SPPHs_for_multiple_distroseries(self):
391
derived_distro = self.factory.makeDistribution()
392
spn = self.factory.makeSourcePackageName()
394
self.factory.makeDistroSeries(derived_distro)
395
for counter in xrange(2)]
397
self.factory.makeDistroSeriesParent(derived_series=distroseries)
398
for distroseries in series]
400
for distroseries in series:
401
self.factory.makeSourcePackagePublishingHistory(
402
distroseries, pocket=PackagePublishingPocket.RELEASE,
403
sourcepackagerelease=self.factory.makeSourcePackageRelease(
404
sourcepackagename=spn))
407
(dsp.derived_series, len(find_waiting_jobs(
408
dsp.derived_series, spn, dsp.parent_series)))
411
dict((distroseries, 1) for distroseries in series),
414
def test_createForSPPHs_behaves_sensibly_if_job_already_exists(self):
415
# If a job already existed, createForSPPHs may create a
416
# redundant one but it certainly won't do anything weird like
417
# delete what was there or create too many.
418
dsp = self.factory.makeDistroSeriesParent()
419
spph = self.factory.makeSourcePackagePublishingHistory(
420
dsp.parent_series, pocket=PackagePublishingPocket.RELEASE)
421
spn = spph.sourcepackagerelease.sourcepackagename
423
create_jobs = range(1, 3)
424
for counter in create_jobs:
425
self.getJobSource().createForSPPHs([spph])
427
job_count = len(find_waiting_jobs(
428
dsp.derived_series, spn, dsp.parent_series))
429
self.assertIn(job_count, create_jobs)
431
def test_createForSPPHs_creates_no_jobs_for_ppas(self):
432
dsp = self.factory.makeDistroSeriesParent()
433
series = dsp.parent_series
434
spph = self.factory.makeSourcePackagePublishingHistory(
435
series, pocket=PackagePublishingPocket.RELEASE,
436
archive=self.factory.makeArchive(
437
distribution=series.distribution, purpose=ArchivePurpose.PPA))
438
spn = spph.sourcepackagerelease.sourcepackagename
439
self.getJobSource().createForSPPHs([spph])
440
self.assertContentEqual(
441
[], find_waiting_jobs(dsp.derived_series, spn, dsp.parent_series))
325
443
def test_massCreateForSeries_obeys_feature_flag(self):
326
444
self.useFixture(FeatureFixture({FEATURE_FLAG_ENABLE_MODULE: ''}))
327
445
dsp = self.factory.makeDistroSeriesParent()