960
961
distro.name, suite, queue, terms, component.name,
961
962
section.name, priority_name, display)
964
def parseUploadSummaryLine(self, output_line):
965
"""Parse an output line from `QueueAction.displayItem`.
967
:param output_line: A line of output text from `displayItem`.
968
:return: A tuple of displayed items: (id, tag, name, version, age).
970
return tuple(item.strip() for item in output_line.split('|'))
963
972
def test_display_actions_have_privileges_for_PackageCopyJob(self):
964
973
# The methods that display uploads have privileges to work with
965
974
# a PackageUpload that has a copy job.
994
1003
# displayItem can display a source package upload.
995
1004
upload = self.factory.makeSourcePackageUpload()
996
1005
action = self.makeQueueAction(upload)
997
1007
action.displayItem(upload)
998
self.assertNotEqual(0, action.display.call_count)
1009
((output, ), kwargs) = action.display.calls[0]
1010
(upload_id, tag, name, version, age) = self.parseUploadSummaryLine(
1012
self.assertEqual(str(upload.id), upload_id)
1013
self.assertEqual("S-", tag)
1014
self.assertThat(upload.displayname, StartsWith(name))
1015
self.assertThat(upload.package_version, StartsWith(version))
1000
1017
def test_displayItem_displays_PackageUpload_with_PackageCopyJob(self):
1001
1018
# displayItem can display a copy-job package upload.
1002
1019
upload = self.factory.makeCopyJobPackageUpload()
1003
1020
action = self.makeQueueAction(upload)
1004
1022
action.displayItem(upload)
1005
self.assertNotEqual(0, action.display.call_count)
1024
((output, ), kwargs) = action.display.calls[0]
1025
(upload_id, tag, name, version, age) = self.parseUploadSummaryLine(
1027
self.assertEqual(str(upload.id), upload_id)
1028
self.assertEqual("X-", tag)
1029
self.assertThat(upload.displayname, StartsWith(name))
1030
self.assertThat(upload.package_version, StartsWith(version))
1032
def test_makeTag_returns_S_for_source_upload(self):
1033
upload = self.factory.makeSourcePackageUpload()
1034
self.assertEqual('S-', self.makeQueueAction(upload)._makeTag(upload))
1036
def test_makeTag_returns_B_for_binary_upload(self):
1037
upload = self.factory.makeBuildPackageUpload()
1038
self.assertEqual('-B', self.makeQueueAction(upload)._makeTag(upload))
1040
def test_makeTag_returns_SB_for_mixed_upload(self):
1041
upload = self.factory.makeSourcePackageUpload()
1042
upload.addBuild(self.factory.makeBinaryPackageBuild())
1043
self.assertEqual('SB', self.makeQueueAction(upload)._makeTag(upload))
1045
def test_makeTag_returns_X_for_copy_job_upload(self):
1046
upload = self.factory.makeCopyJobPackageUpload()
1047
self.assertEqual('X-', self.makeQueueAction(upload)._makeTag(upload))
1049
def test_makeTag_returns_dashes_for_custom_upload(self):
1050
upload = self.factory.makeCustomPackageUpload()
1051
self.assertEqual('--', self.makeQueueAction(upload)._makeTag(upload))
1007
1053
def test_displayInfo_displays_PackageUpload_with_source(self):
1008
1054
# displayInfo can display a source package upload.