Esempio n. 1
0
class TwistedCircuitBreakerTestCase(unittest.TestCase):
    def setUp(self):
        self.clock = task.Clock()
        self.log = mock()
        when(self.log).getChild('ctxt').thenReturn(self.log)
        self.circuit_breaker = TwistedCircuitBreakerSet(self.clock, self.log)

    def test_context_exit_with_inline_callbacks_resets_circuit(self):
        @defer.inlineCallbacks
        def test():
            with self.circuit_breaker.context('ctxt') as breaker:
                breaker.state = 'half-open'
                yield defer.succeed(None)
                defer.returnValue(None)

        test()
        self.assertEquals(self.circuit_breaker.circuits['ctxt'].state,
                          'closed')
Esempio n. 2
0
class TwistedCircuitBreakerTestCase(unittest.TestCase):

    def setUp(self):
        self.clock = task.Clock()
        self.log = mock()
        when(self.log).getChild('ctxt').thenReturn(self.log)
        self.circuit_breaker = TwistedCircuitBreakerSet(self.clock, self.log)

    def test_context_exit_with_inline_callbacks_resets_circuit(self):
        @defer.inlineCallbacks
        def test():
            with self.circuit_breaker.context('ctxt') as breaker:
                breaker.state = 'half-open'
                yield defer.succeed(None)
                defer.returnValue(None)
        test()
        self.assertEquals(self.circuit_breaker.circuits['ctxt'].state,
                          'closed')
Esempio n. 3
0
 def setUp(self):
     self.clock = task.Clock()
     self.log = mock()
     when(self.log).getChild('ctxt').thenReturn(self.log)
     self.circuit_breaker = TwistedCircuitBreakerSet(self.clock, self.log)
Esempio n. 4
0
 def setUp(self):
     self.clock = task.Clock()
     self.log = mock()
     when(self.log).getChild('ctxt').thenReturn(self.log)
     self.circuit_breaker = TwistedCircuitBreakerSet(self.clock,
        self.log)