Ejemplo n.º 1
0
 def set_up(self, times):
     self.throttler = mock.Mock()
     self.timer = mock.Mock(side_effect=times)
     self.reporter = DynamicThrottling(
         self.throttler,
         timer=self.timer
     )
Ejemplo n.º 2
0
 def set_up(self, times):
     self.throttler = mock.Mock()
     self.timer = mock.Mock(side_effect=times)
     self.reporter = DynamicThrottling(self.throttler, timer=self.timer)
Ejemplo n.º 3
0
class TestDynamicThrottlingTimer(unittest.TestCase):
    def set_up(self, times):
        self.throttler = mock.Mock()
        self.timer = mock.Mock(side_effect=times)
        self.reporter = DynamicThrottling(self.throttler, timer=self.timer)

    def test_something(self):
        self.set_up([1, 2])
        self.reporter.start()
        self.reporter.stop(0)
        self.throttler.adjust_delta.assert_called_once_with(1)

    def test_delta_cleared_on_every_run(self):
        self.set_up([1, 2, 4, 7])
        self.reporter.start()
        self.reporter.stop(0)
        self.throttler.adjust_delta.assert_called_with(1)
        self.reporter.start()
        self.reporter.stop(0)
        self.throttler.adjust_delta.assert_called_with(3)
Ejemplo n.º 4
0
class TestDynamicThrottlingTimer(unittest.TestCase):

    def set_up(self, times):
        self.throttler = mock.Mock()
        self.timer = mock.Mock(side_effect=times)
        self.reporter = DynamicThrottling(
            self.throttler,
            timer=self.timer
        )

    def test_something(self):
        self.set_up([1, 2])
        self.reporter.start()
        self.reporter.stop(0)
        self.throttler.adjust_delta.assert_called_once_with(1)

    def test_delta_cleared_on_every_run(self):
        self.set_up([1, 2, 4, 7])
        self.reporter.start()
        self.reporter.stop(0)
        self.throttler.adjust_delta.assert_called_with(1)
        self.reporter.start()
        self.reporter.stop(0)
        self.throttler.adjust_delta.assert_called_with(3)