def test_notify_changes_tail_method(self): throttle_time = 0 context = TailContext(throttle_time) self.assertTrue(isinstance(context.tail_method, TailMultiLineMethod)) slow_down = notifications.SlowDown(context) slow_down.notify(WarningMessage(), DummyLog()) self.assertTrue(isinstance(context.tail_method, TailOneLineMethod))
def test_notify_no_change_context(self): throttle_time = 0 context = TailContext(throttle_time) self.assertTrue(isinstance(context.tail_method, TailMultiLineMethod)) slow_down = notifications.SlowDown(context) slow_down.notify(NormalMessage(), DummyLog()) self.assertFalse(slow_down.triggered)
def test_notify_back_to_default_after_1_tails(self): throttle_time = 0 context = TailContext(throttle_time) self.assertTrue(isinstance(context.tail_method, TailMultiLineMethod)) slow_down = notifications.SlowDown(context) notifications.SlowDown.MAX_COUNT = 1 slow_down.notify(WarningMessage(), DummyLog()) self.assertTrue(isinstance(context.tail_method, TailOneLineMethod)) slow_down.notify(NormalMessage(), DummyLog()) slow_down.notify(NormalMessage(), DummyLog()) self.assertTrue(isinstance(context.tail_method, TailMultiLineMethod))
def test_instantiates(self): throttle_time = 0 context = TailContext(throttle_time) slow_down = notifications.SlowDown(context) self.assertTrue(isinstance(slow_down, notifications.SlowDown))
def test_get_trace(self): throttle_time = 0 context = TailContext(throttle_time, default_tail_method=TailMethod) trace = context.get_trace(DummyLog()) self.assertEqual(trace, "hi")
def test_changes_tail_method(self): throttle_time = 0 context = TailContext(throttle_time, default_tail_method=TailMethod) context.change_tail_method(OtherTailMethod()) self.assertTrue(isinstance(context.tail_method, OtherTailMethod))
def test_instantiates(self): throttle_time = 0 context = TailContext(throttle_time, default_tail_method=TailMethod) self.assertTrue(isinstance(context, TailContext))