924
927
'override binary pmount', component_name='partner')
930
class TestQueueActionLite(TestCaseWithFactory):
931
"""A lightweight unit test case for `QueueAction`.
933
Meant for detailed tests that would be too expensive for full end-to-end
937
layer = LaunchpadZopelessLayer
939
def makeQueueAction(self, package_upload, distroseries=None):
940
"""Create a `QueueAction` for use with a `PackageUpload`.
942
The action's `display` method is set to a `FakeMethod`.
944
if distroseries is None:
945
distroseries = self.factory.makeDistroSeries(
946
status=SeriesStatus.CURRENT)
947
distro = distroseries.distribution
948
if package_upload is None:
949
package_upload = self.factory.makePackageUpload(
950
distroseries=distroseries, archive=distro.main_archive)
951
component = self.factory.makeComponent()
952
section = self.factory.makeSection()
953
suite = "%s-%s" % (distroseries.name, "release")
955
priority_name = "STANDARD"
956
display = FakeMethod()
959
distro.name, suite, queue, terms, component.name,
960
section.name, priority_name, display)
962
def test_display_actions_have_privileges_for_PackageCopyJob(self):
963
# The methods that display uploads have privileges to work with
964
# a PackageUpload that has a copy job.
965
# Bundling tests for multiple operations into one test because
966
# the database user change requires a costly commit.
967
upload = self.factory.makeCopyJobPackageUpload()
968
action = self.makeQueueAction(upload)
969
self.layer.txn.commit()
970
self.layer.switchDbUser(config.uploadqueue.dbuser)
972
action.displayItem(upload)
973
self.assertNotEqual(0, action.display.call_count)
974
action.display.calls = []
975
action.displayInfo(upload)
976
self.assertNotEqual(0, action.display.call_count)
978
def test_accept_actions_have_privileges_for_PackageCopyJob(self):
979
# The script also has privileges to approve uploads that have
981
distroseries = self.factory.makeDistroSeries(
982
status=SeriesStatus.CURRENT)
983
upload = self.factory.makeCopyJobPackageUpload(distroseries)
984
self.layer.txn.commit()
985
self.layer.switchDbUser(config.uploadqueue.dbuser)
986
upload.acceptFromQueue(DevNullLogger(), dry_run=True)
987
# Flush changes to make sure we're not caching any updates that
988
# the database won't allow. If this passes, we've got the
990
IStore(upload).flush()
992
def test_displayItem_displays_PackageUpload_with_source(self):
993
# displayItem can display a source package upload.
994
upload = self.factory.makeSourcePackageUpload()
995
action = self.makeQueueAction(upload)
996
action.displayItem(upload)
997
self.assertNotEqual(0, action.display.call_count)
999
def test_displayItem_displays_PackageUpload_with_PackageCopyJob(self):
1000
# displayItem can display a copy-job package upload.
1001
upload = self.factory.makeCopyJobPackageUpload()
1002
action = self.makeQueueAction(upload)
1003
action.displayItem(upload)
1004
self.assertNotEqual(0, action.display.call_count)
1006
def test_displayInfo_displays_PackageUpload_with_source(self):
1007
# displayInfo can display a source package upload.
1008
upload = self.factory.makeSourcePackageUpload()
1009
action = self.makeQueueAction(upload)
1010
action.displayInfo(upload)
1011
self.assertNotEqual(0, action.display.call_count)
1013
def test_displayInfo_displays_PackageUpload_with_PackageCopyJob(self):
1014
# displayInfo can display a copy-job package upload.
1015
upload = self.factory.makeCopyJobPackageUpload()
1016
action = self.makeQueueAction(upload)
1017
action.displayInfo(upload)
1018
self.assertNotEqual(0, action.display.call_count)
927
1021
class TestQueuePageClosingBugs(TestCaseWithFactory):
928
1022
# The distroseries +queue page can close bug when accepting
929
1023
# packages. Unit tests for that belong here.