~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-06-09 10:49:32 UTC
  • mfrom: (7675.1190.7 db-bug-793382)
  • Revision ID: launchpad@pqm.canonical.com-20110609104932-ctzgwbfn80x1c9ll
[r=henninge][bug=793382] Bring requestUpgrades back to constant query
 count.

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
        self.assertEquals(False, job.include_binaries)
119
119
        self.assertEquals(PackageCopyPolicy.MASS_SYNC, job.copy_policy)
120
120
 
 
121
    def test_createMultiple_creates_one_job_per_copy(self):
 
122
        mother = self.factory.makeDistroSeriesParent()
 
123
        derived_series = mother.derived_series
 
124
        father = self.factory.makeDistroSeriesParent(
 
125
            derived_series=derived_series)
 
126
        mother_package = self.factory.makeSourcePackageName()
 
127
        father_package = self.factory.makeSourcePackageName()
 
128
        job_source = getUtility(IPlainPackageCopyJobSource)
 
129
        copy_tasks = [
 
130
            (
 
131
                mother_package.name,
 
132
                "1.5mother1",
 
133
                mother.parent_series.main_archive,
 
134
                derived_series.main_archive,
 
135
                PackagePublishingPocket.RELEASE,
 
136
                ),
 
137
            (
 
138
                father_package.name,
 
139
                "0.9father1",
 
140
                father.parent_series.main_archive,
 
141
                derived_series.main_archive,
 
142
                PackagePublishingPocket.UPDATES,
 
143
                ),
 
144
            ]
 
145
        job_ids = list(
 
146
            job_source.createMultiple(mother.derived_series, copy_tasks))
 
147
        jobs = list(job_source.getActiveJobs(derived_series.main_archive))
 
148
        self.assertContentEqual(job_ids, [job.id for job in jobs])
 
149
        self.assertEqual(len(copy_tasks), len(set([job.job for job in jobs])))
 
150
        # Get jobs into the same order as copy_tasks, for ease of
 
151
        # comparison.
 
152
        if jobs[0].package_name != mother_package.name:
 
153
            jobs = reversed(jobs)
 
154
        requested_copies = [
 
155
            (
 
156
                job.package_name,
 
157
                job.package_version,
 
158
                job.source_archive,
 
159
                job.target_archive,
 
160
                job.target_pocket,
 
161
                )
 
162
            for job in jobs]
 
163
        self.assertEqual(copy_tasks, requested_copies)
 
164
 
121
165
    def test_getActiveJobs(self):
122
166
        # getActiveJobs() can retrieve all active jobs for an archive.
123
167
        distroseries = self.factory.makeDistroSeries()
449
493
        # metadata.
450
494
        name = self.factory.makeSourcePackageName()
451
495
        component = self.factory.makeComponent()
452
 
        section=self.factory.makeSection()
 
496
        section = self.factory.makeSection()
453
497
        pcj = self.factory.makePlainPackageCopyJob()
454
498
        self.layer.txn.commit()
455
499
        self.layer.switchDbUser('sync_packages')
474
518
        # the metadata.
475
519
        name = self.factory.makeSourcePackageName()
476
520
        component = self.factory.makeComponent()
477
 
        section=self.factory.makeSection()
 
521
        section = self.factory.makeSection()
478
522
        pcj = self.factory.makePlainPackageCopyJob(
479
523
            package_name=name.name, package_version="1.0")
480
524
        self.layer.txn.commit()