← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/launchpad/masscreate-bug-835040 into lp:launchpad

 

Raphaël Victor Badin has proposed merging lp:~rvb/launchpad/masscreate-bug-835040 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #835040 in Launchpad itself: "script that initializes a new distro series failed with a ProgrammingError"
  https://bugs.launchpad.net/launchpad/+bug/835040

For more details, see:
https://code.launchpad.net/~rvb/launchpad/masscreate-bug-835040/+merge/73495

This branch fixes a bug in create_multiple_jobs (lib/lp/soyuz/model/distroseriesdifferencejob.py). If no DistroSeriesDifferenceJob needs to be created, we should return early instead of issuing an SQL statement that will fail.

= Tests =

./bin/test -vvc test_distroseriesdifferencejob test_create_multiple_jobs_no_jobs

= Q/A =

See the bug report to initialize a new series with exactly the same settings. Run the initialization job.
-- 
https://code.launchpad.net/~rvb/launchpad/masscreate-bug-835040/+merge/73495
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/launchpad/masscreate-bug-835040 into lp:launchpad.
=== modified file 'lib/lp/soyuz/model/distroseriesdifferencejob.py'
--- lib/lp/soyuz/model/distroseriesdifferencejob.py	2011-08-26 09:28:20 +0000
+++ lib/lp/soyuz/model/distroseriesdifferencejob.py	2011-08-31 09:26:38 +0000
@@ -112,6 +112,10 @@
         SourcePackagePublishingHistory.distroseries == derived_series.id,
         SourcePackagePublishingHistory.status.is_in(active_publishing_status))
     nb_jobs = source_package_releases.count()
+
+    if nb_jobs == 0:
+        return []
+
     sourcepackagenames = source_package_releases.values(
         SourcePackageRelease.sourcepackagenameID)
     job_ids = Job.createMultiple(store, nb_jobs)

=== modified file 'lib/lp/soyuz/tests/test_distroseriesdifferencejob.py'
--- lib/lp/soyuz/tests/test_distroseriesdifferencejob.py	2011-08-26 09:17:08 +0000
+++ lib/lp/soyuz/tests/test_distroseriesdifferencejob.py	2011-08-31 09:26:38 +0000
@@ -215,6 +215,15 @@
 
         self.assertEqual(JobStatus.WAITING, dsdjob.job.status)
 
+    def test_create_multiple_jobs_no_jobs(self):
+        # If no job needs to be created, create_multiple_jobs
+        # returns an empty list.
+        dsp = self.factory.makeDistroSeriesParent()
+        job_ids = create_multiple_jobs(
+            dsp.derived_series, dsp.parent_series)
+
+        self.assertEqual([], job_ids)
+
     def find_waiting_jobs_finds_waiting_jobs(self):
         dsp = self.factory.makeDistroSeriesParent()
         package = self.factory.makeSourcePackageName()