Exemple #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
     )
 def set_up(self, times):
     self.throttler = mock.Mock()
     self.timer = mock.Mock(side_effect=times)
     self.reporter = DynamicThrottling(self.throttler, timer=self.timer)
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)
Exemple #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)