443
442
self.assertEqual(job.package_name, upload.package_name)
444
443
self.assertEqual(job.package_version, upload.package_version)
446
def test_displayarchs_for_copy_job_is_source(self):
445
def test_displayarchs_for_copy_job_is_sync(self):
447
446
# For copy jobs, displayarchs is "source."
448
447
upload, job = self.makeUploadWithPackageCopyJob()
449
self.assertEqual('source', upload.displayarchs)
448
self.assertEqual('sync', upload.displayarchs)
451
450
def test_component_and_section_name(self):
452
451
# An upload with a copy job takes its component and section
789
788
upload_set.getAll(
790
789
distroseries, name=spn.name, version=upload.displayversion))
793
class TestPackageUploadWithPackageCopyJob(TestCaseWithFactory):
795
layer = LaunchpadZopelessLayer
796
dbuser = config.uploadqueue.dbuser
798
def test_package_copy_job_property(self):
799
# Test that we can set and get package_copy_job.
800
pcj = removeSecurityProxy(
801
self.factory.makePlainPackageCopyJob()).context
802
pu = self.factory.makePackageUpload(package_copy_job=pcj)
805
self.assertEqual(pcj, pu.package_copy_job)
807
def test_getByPackageCopyJobIDs(self):
808
pcj = removeSecurityProxy(
809
self.factory.makePlainPackageCopyJob()).context
810
pu = self.factory.makePackageUpload(package_copy_job=pcj)
811
result = getUtility(IPackageUploadSet).getByPackageCopyJobIDs(
813
self.assertEqual(pu, result.one())
815
def test_overrideSource_with_copy_job(self):
816
# The overrides should be stored in the job's metadata.
817
plain_copy_job = self.factory.makePlainPackageCopyJob()
818
pcj = removeSecurityProxy(plain_copy_job).context
819
pu = self.factory.makePackageUpload(package_copy_job=pcj)
820
component = getUtility(IComponentSet)['restricted']
821
section = getUtility(ISectionSet)['games']
823
expected_metadata = {
824
'component_override': component.name,
825
'section_override': section.name
827
expected_metadata.update(plain_copy_job.metadata)
829
pu.overrideSource(component, section, allowed_components=[component])
832
expected_metadata, plain_copy_job.metadata)
834
def test_acceptFromQueue_with_copy_job(self):
835
# acceptFromQueue should accept the upload and resume the copy
837
plain_copy_job = self.factory.makePlainPackageCopyJob()
838
pcj = removeSecurityProxy(plain_copy_job).context
839
pu = self.factory.makePackageUpload(package_copy_job=pcj)
840
self.assertEqual(PackageUploadStatus.NEW, pu.status)
841
plain_copy_job.suspend()
845
self.assertEqual(PackageUploadStatus.ACCEPTED, pu.status)
846
self.assertEqual(JobStatus.WAITING, plain_copy_job.status)
848
def test_rejectFromQueue_with_copy_job(self):
849
# rejectFromQueue will reject the upload and fail the copy job.
850
plain_copy_job = self.factory.makePlainPackageCopyJob()
851
pcj = removeSecurityProxy(plain_copy_job).context
852
pu = self.factory.makePackageUpload(package_copy_job=pcj)
853
plain_copy_job.suspend()
857
self.assertEqual(PackageUploadStatus.REJECTED, pu.status)
858
self.assertEqual(JobStatus.FAILED, plain_copy_job.status)
860
# It cannot be resurrected after rejection.
862
QueueInconsistentStateError, pu.acceptFromQueue, None)