~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/archivepublisher/tests/test_publish_ftpmaster.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-05 08:09:44 UTC
  • mfrom: (13583.1.7 bug-819674)
  • Revision ID: launchpad@pqm.canonical.com-20110805080944-80d1d1xkmw343lle
[r=wgrant][bug=819674] Make sure publish-ftpmaster handles ctrl-C.

Show diffs side-by-side

added added

removed removed

Lines of Context:
736
736
                "Did not find expected marker for %s."
737
737
                % archive.purpose.title)
738
738
 
 
739
    def test_publish_reraises_exception(self):
 
740
        # If an Exception comes up while publishing, it bubbles up out
 
741
        # of the publish method even though the method must intercept
 
742
        # it for its own purposes.
 
743
        class MoonPhaseError(Exception):
 
744
            """Simulated failure."""
 
745
 
 
746
        message = self.factory.getUniqueString()
 
747
        script = self.makeScript()
 
748
        script.publishAllUploads = FakeMethod(failure=MoonPhaseError(message))
 
749
        script.setUp()
 
750
        self.assertRaisesWithContent(MoonPhaseError, message, script.publish)
 
751
 
 
752
    def test_publish_obeys_keyboard_interrupt(self):
 
753
        # Similar to an Exception, a keyboard interrupt does not get
 
754
        # swallowed.
 
755
        message = self.factory.getUniqueString()
 
756
        script = self.makeScript()
 
757
        script.publishAllUploads = FakeMethod(
 
758
            failure=KeyboardInterrupt(message))
 
759
        script.setUp()
 
760
        self.assertRaisesWithContent(
 
761
            KeyboardInterrupt, message, script.publish)
 
762
 
 
763
    def test_publish_recovers_working_dists_on_exception(self):
 
764
        # If an Exception comes up while publishing, the publish method
 
765
        # recovers its working directory.
 
766
        class MoonPhaseError(Exception):
 
767
            """Simulated failure."""
 
768
 
 
769
        failure = MoonPhaseError(self.factory.getUniqueString())
 
770
 
 
771
        script = self.makeScript()
 
772
        script.publishAllUploads = FakeMethod(failure=failure)
 
773
        script.recoverArchiveWorkingDir = FakeMethod()
 
774
        script.setUp()
 
775
 
 
776
        try:
 
777
            script.publish()
 
778
        except MoonPhaseError:
 
779
            pass
 
780
 
 
781
        self.assertEqual(1, script.recoverArchiveWorkingDir.call_count)
 
782
 
 
783
    def test_publish_recovers_working_dists_on_ctrl_C(self):
 
784
        # If the user hits ctrl-C while publishing, the publish method
 
785
        # recovers its working directory.
 
786
        failure = KeyboardInterrupt("Ctrl-C!")
 
787
 
 
788
        script = self.makeScript()
 
789
        script.publishAllUploads = FakeMethod(failure=failure)
 
790
        script.recoverArchiveWorkingDir = FakeMethod()
 
791
        script.setUp()
 
792
 
 
793
        try:
 
794
            script.publish()
 
795
        except KeyboardInterrupt:
 
796
            pass
 
797
 
 
798
        self.assertEqual(1, script.recoverArchiveWorkingDir.call_count)
 
799
 
739
800
 
740
801
class TestCreateDistroSeriesIndexes(TestCaseWithFactory, HelpersMixin):
741
802
    """Test initial creation of archive indexes for a `DistroSeries`."""