~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-06-23 06:49:43 UTC
  • mfrom: (13277.2.2 bug-799680)
  • Revision ID: launchpad@pqm.canonical.com-20110623064943-cuquwlhnwoa0xhj4
[r=julian-edwards][bug=799680] Show architecture for copy-job uploads
        as "sync."

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
import shutil
11
11
from StringIO import StringIO
12
12
import tempfile
 
13
from testtools.matchers import StartsWith
13
14
from unittest import TestCase
14
15
 
15
16
from zope.component import getUtility
960
961
            distro.name, suite, queue, terms, component.name,
961
962
            section.name, priority_name, display)
962
963
 
 
964
    def parseUploadSummaryLine(self, output_line):
 
965
        """Parse an output line from `QueueAction.displayItem`.
 
966
 
 
967
        :param output_line: A line of output text from `displayItem`.
 
968
        :return: A tuple of displayed items: (id, tag, name, version, age).
 
969
        """
 
970
        return tuple(item.strip() for item in output_line.split('|'))
 
971
 
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)
 
1006
 
997
1007
        action.displayItem(upload)
998
 
        self.assertNotEqual(0, action.display.call_count)
 
1008
 
 
1009
        ((output, ), kwargs) = action.display.calls[0]
 
1010
        (upload_id, tag, name, version, age) = self.parseUploadSummaryLine(
 
1011
            output)
 
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))
999
1016
 
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)
 
1021
 
1004
1022
        action.displayItem(upload)
1005
 
        self.assertNotEqual(0, action.display.call_count)
 
1023
 
 
1024
        ((output, ), kwargs) = action.display.calls[0]
 
1025
        (upload_id, tag, name, version, age) = self.parseUploadSummaryLine(
 
1026
            output)
 
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))
 
1031
 
 
1032
    def test_makeTag_returns_S_for_source_upload(self):
 
1033
        upload = self.factory.makeSourcePackageUpload()
 
1034
        self.assertEqual('S-', self.makeQueueAction(upload)._makeTag(upload))
 
1035
 
 
1036
    def test_makeTag_returns_B_for_binary_upload(self):
 
1037
        upload = self.factory.makeBuildPackageUpload()
 
1038
        self.assertEqual('-B', self.makeQueueAction(upload)._makeTag(upload))
 
1039
 
 
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))
 
1044
 
 
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))
 
1048
 
 
1049
    def test_makeTag_returns_dashes_for_custom_upload(self):
 
1050
        upload = self.factory.makeCustomPackageUpload()
 
1051
        self.assertEqual('--', self.makeQueueAction(upload)._makeTag(upload))
1006
1052
 
1007
1053
    def test_displayInfo_displays_PackageUpload_with_source(self):
1008
1054
        # displayInfo can display a source package upload.