コード例 #1
0
    def testWaitFailed(self):
        basedir = "test_slave_commands_base.wait.failed"
        b = FakeSlaveBuilder(False, basedir)
        clock = task.Clock()

        def cb():
            d = defer.Deferred()
            clock.callLater(1, d.errback, AssertionError())
            return d

        waitCommandRegistry['foo'] = cb

        w = WaitCommand(b, 1, {'handle': 'foo'})
        w._reactor = clock

        d1 = w.doStart()

        def _check(ign):
            self.failUnless({'rc': 1} in b.updates, b.updates)
            self.failUnlessEqual(w.interrupted, False)

        d1.addCallback(_check)
        # Advance 1 second to get our callback called
        clock.advance(1)

        # Advance 1 second to call the callback's deferred (the d returned by
        # cb)
        clock.advance(1)
        return d1
コード例 #2
0
    def testWaitFailed(self):
        basedir = "test_slave_commands_base.wait.failed"
        b = FakeSlaveBuilder(False, basedir)
        clock = task.Clock()

        def cb():
            d = defer.Deferred()
            clock.callLater(1, d.errback, AssertionError())
            return d

        waitCommandRegistry['foo'] = cb

        w = WaitCommand(b, 1, {'handle': 'foo'})
        w._reactor = clock

        d1 = w.doStart()

        def _check(ign):
            self.failUnless({'rc': 1} in b.updates, b.updates)
            self.failUnlessEqual(w.interrupted, False)
        d1.addCallback(_check)
        # Advance 1 second to get our callback called
        clock.advance(1)

        # Advance 1 second to call the callback's deferred (the d returned by
        # cb)
        clock.advance(1)
        return d1
コード例 #3
0
    def testWaitInterrupt(self):
        basedir = "test_slave_commands_base.wait.interrupt"
        b = FakeSlaveBuilder(False, basedir)
        clock = task.Clock()

        def cb():
            d = defer.Deferred()
            clock.callLater(1, d.callback, None)
            return d

        waitCommandRegistry['foo'] = cb

        w = WaitCommand(b, 1, {'handle': 'foo'})
        w._reactor = clock

        d1 = w.doStart()

        def _check(ign):
            self.failUnless({'rc': 2} in b.updates, b.updates)
            self.failUnlessEqual(w.interrupted, True)

        d1.addCallback(_check)
        # Advance 1 second to get our callback called
        clock.advance(1)

        # Now interrupt it
        w.interrupt()
        # And again, to make sure nothing bad happened
        clock.advance(0.1)
        w.interrupt()
        return d1
コード例 #4
0
    def testWaitInterrupt(self):
        basedir = "test_slave_commands_base.wait.interrupt"
        b = FakeSlaveBuilder(False, basedir)
        clock = task.Clock()

        def cb():
            d = defer.Deferred()
            clock.callLater(1, d.callback, None)
            return d

        waitCommandRegistry['foo'] = cb

        w = WaitCommand(b, 1, {'handle': 'foo'})
        w._reactor = clock

        d1 = w.doStart()

        def _check(ign):
            self.failUnless({'rc': 2} in b.updates, b.updates)
            self.failUnlessEqual(w.interrupted, True)
        d1.addCallback(_check)
        # Advance 1 second to get our callback called
        clock.advance(1)

        # Now interrupt it
        w.interrupt()
        # And again, to make sure nothing bad happened
        clock.advance(0.1)
        w.interrupt()
        return d1