~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py

Merge with trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from canonical.testing.layers import LaunchpadZopelessLayer
24
24
from lp.buildmaster.interfaces.buildbase import BuildStatus
25
25
from lp.registry.interfaces.pocket import PackagePublishingPocket
 
26
from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet
26
27
from lp.soyuz.interfaces.packageset import IPackagesetSet
27
28
from lp.soyuz.interfaces.sourcepackageformat import SourcePackageFormat
28
29
from lp.soyuz.model.distroarchseries import DistroArchSeries
87
88
            self.ubuntu['breezy-autotest'])
88
89
        ids = InitialiseDistroSeries(foobuntu)
89
90
        self.assertRaisesWithContent(
90
 
            InitialisationError,"Parent series queues are not empty.",
 
91
            InitialisationError, "Parent series queues are not empty.",
91
92
            ids.check)
92
93
 
93
94
    def assertDistroSeriesInitialisedCorrectly(self, foobuntu):
191
192
 
192
193
    def test_copying_packagesets(self):
193
194
        # If a parent series has packagesets, we should copy them
 
195
        uploader = self.factory.makePerson()
194
196
        test1 = getUtility(IPackagesetSet).new(
195
197
            u'test1', u'test 1 packageset', self.hoary.owner,
196
198
            distroseries=self.hoary)
199
201
            distroseries=self.hoary)
200
202
        test3 = getUtility(IPackagesetSet).new(
201
203
            u'test3', u'test 3 packageset', self.hoary.owner,
202
 
            distroseries=self.hoary)
203
 
        foobuntu = self._create_distroseries(self.hoary)
204
 
        self._set_pending_to_failed(self.hoary)
205
 
        transaction.commit()
206
 
        ids = InitialiseDistroSeries(foobuntu)
207
 
        ids.check()
208
 
        ids.initialise()
 
204
            distroseries=self.hoary, related_set=test2)
 
205
        test1.addSources('pmount')
 
206
        getUtility(IArchivePermissionSet).newPackagesetUploader(
 
207
            self.hoary.main_archive, uploader, test1)
 
208
        foobuntu = self._full_initialise()
209
209
        # We can fetch the copied sets from foobuntu
210
210
        foobuntu_test1 = getUtility(IPackagesetSet).getByName(
211
211
            u'test1', distroseries=foobuntu)
219
219
        self.assertEqual(test2.description, foobuntu_test2.description)
220
220
        self.assertEqual(test3.description, foobuntu_test3.description)
221
221
        self.assertEqual(foobuntu_test1.relatedSets().one(), test1)
222
 
        self.assertEqual(foobuntu_test2.relatedSets().one(), test2)
223
 
        self.assertEqual(foobuntu_test3.relatedSets().one(), test3)
 
222
        self.assertEqual(
 
223
            list(foobuntu_test2.relatedSets()),
 
224
            [test2, test3, foobuntu_test3])
 
225
        self.assertEqual(
 
226
            list(foobuntu_test3.relatedSets()),
 
227
            [test2, foobuntu_test2, test3])
 
228
        # The contents of the packagesets will have been copied.
 
229
        foobuntu_srcs = foobuntu_test1.getSourcesIncluded(
 
230
            direct_inclusion=True)
 
231
        hoary_srcs = test1.getSourcesIncluded(direct_inclusion=True)
 
232
        self.assertEqual(foobuntu_srcs, hoary_srcs)
 
233
        # The uploader can also upload to the new distroseries.
 
234
        self.assertTrue(
 
235
            getUtility(IArchivePermissionSet).isSourceUploadAllowed(
 
236
                self.hoary.main_archive, 'pmount', uploader,
 
237
                distroseries=self.hoary))
 
238
        self.assertTrue(
 
239
            getUtility(IArchivePermissionSet).isSourceUploadAllowed(
 
240
                foobuntu.main_archive, 'pmount', uploader,
 
241
                distroseries=foobuntu))
224
242
 
225
243
    def test_script(self):
226
244
        # Do an end-to-end test using the command-line tool