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')
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)