~alecu/ubuntuone-client/gsd-plugin-remove-quota

« back to all changes in this revision

Viewing changes to tests/syncdaemon/test_action_queue.py

  • Committer: Tarmac
  • Author(s): Facundo Batista
  • Date: 2011-03-29 20:09:44 UTC
  • mfrom: (928.1.4 log-enhancements)
  • Revision ID: tarmac-20110329200944-9rjmman2ysjw0fkt
Some logging enhancements

Show diffs side-by-side

added added

removed removed

Lines of Context:
1719
1719
    def test_go_run_bad_release_pathlock(self):
1720
1720
        """If run went bad, release the pathlock."""
1721
1721
        called = []
1722
 
        self.cmd.run = lambda: defer.fail(ValueError())
 
1722
        self.cmd.run = lambda: defer.fail(ValueError("error message"))
1723
1723
        self.cmd._acquire_pathlock = lambda: defer.succeed(
1724
1724
                                                lambda: called.append(True))
1725
1725
 
1726
 
        try:
1727
 
            yield self.cmd.go()
1728
 
        except ValueError:
1729
 
            pass # consume!
1730
 
        else:
1731
 
            self.fail("It didn't raise an exception!")
 
1726
        yield self.cmd.go()
1732
1727
        self.assertTrue(called)
1733
1728
 
 
1729
        # check exception to assure a traceback was logged, and check the
 
1730
        # messages in ERROR (the real logging level); finally, clean the
 
1731
        # records as if we leave them with the exception the test will fail
 
1732
        self.assertTrue(self.handler.check_exception(ValueError))
 
1733
        self.assertTrue(self.handler.check_error("Error running the command",
 
1734
                                                 "error message"))
 
1735
        self.handler.records = []
 
1736
 
1734
1737
    def test_run_initial(self):
1735
1738
        """Call ._start, log, and set running."""
1736
1739
        called = []
1737
 
        self.cmd._start = lambda: called.append(True)# or defer.succeed(True)
 
1740
        d = defer.Deferred()
 
1741
        self.cmd._start = lambda: called.append(True) or d
1738
1742
 
 
1743
        # run, and will lock in the _start
1739
1744
        self.cmd.run()
1740
 
        self.assertFalse(self.cmd.running)
1741
1745
        self.assertTrue(called)
1742
1746
        self.assertTrue(self.handler.check_debug('starting'))
1743
1747
 
 
1748
        # release the _start, check log and that it still not running
 
1749
        d.callback(True)
 
1750
        self.assertTrue(self.handler.check_debug('started'))
 
1751
        self.assertFalse(self.cmd.running)
 
1752
 
1744
1753
    def test_run_stop_if_cancelled_while_start(self):
1745
1754
        """Cancelled while _start."""
1746
1755
        self.rq.queue(self.cmd)