939
940
layer = LaunchpadZopelessLayer
941
def makeQueueAction(self, package_upload, distroseries=None):
942
def makeQueueAction(self, package_upload, distroseries=None,
943
component=None, section=None,
944
action_type=QueueAction):
942
945
"""Create a `QueueAction` for use with a `PackageUpload`.
944
947
The action's `display` method is set to a `FakeMethod`.
946
949
if distroseries is None:
947
950
distroseries = self.factory.makeDistroSeries(
948
status=SeriesStatus.CURRENT)
951
status=SeriesStatus.CURRENT,
952
name="distroseriestestingpcjs")
949
953
distro = distroseries.distribution
950
954
if package_upload is None:
951
955
package_upload = self.factory.makePackageUpload(
952
956
distroseries=distroseries, archive=distro.main_archive)
953
component = self.factory.makeComponent()
954
section = self.factory.makeSection()
955
suite = "%s-%s" % (distroseries.name, "release")
957
if component is None:
958
component = self.factory.makeComponent()
960
section = self.factory.makeSection()
961
queue = PackageUploadStatus.NEW
957
962
priority_name = "STANDARD"
958
963
display = FakeMethod()
961
distro.name, suite, queue, terms, component.name,
966
distro.name, distroseries.name, queue, terms, component.name,
962
967
section.name, priority_name, display)
969
def makeQueueActionOverride(self, package_upload, component, section,
971
return self.makeQueueAction(
972
package_upload, distroseries, component, section,
973
action_type=QueueActionOverride)
964
975
def parseUploadSummaryLine(self, output_line):
965
976
"""Parse an output line from `QueueAction.displayItem`.
1029
1040
self.assertThat(upload.displayname, StartsWith(name))
1030
1041
self.assertThat(upload.package_version, StartsWith(version))
1043
def test_override_works_with_PackageCopyJob(self):
1044
# "Sync" PackageUploads can be overridden just like sources,
1046
new_component = self.factory.makeComponent()
1047
new_section = self.factory.makeSection()
1048
pocket = PackagePublishingPocket.RELEASE
1049
upload = self.factory.makeCopyJobPackageUpload(target_pocket=pocket)
1050
action = self.makeQueueActionOverride(
1051
upload, new_component, new_section,
1052
distroseries=upload.distroseries)
1053
# Patch this out because it uses data we don't have in the test;
1054
# it's unnecessary anyway.
1055
self.patch(action, "displayTitle", FakeMethod)
1056
action.terms = ["source", str(upload.id)]
1057
self.layer.txn.commit()
1058
self.layer.switchDbUser(config.uploadqueue.dbuser)
1062
# Overriding a sync means putting the overrides in the job itself.
1064
new_component.name, upload.package_copy_job.component_name)
1066
new_section.name, upload.package_copy_job.section_name)
1032
1068
def test_makeTag_returns_S_for_source_upload(self):
1033
1069
upload = self.factory.makeSourcePackageUpload()
1034
1070
self.assertEqual('S-', self.makeQueueAction(upload)._makeTag(upload))