Exemplo n.º 1
0
    def test_during_2(self):
        now = datetime.datetime.now(datetime.timezone.utc)
        control_info = {
            'start': now - datetime.timedelta(seconds=200),
            'end': now + datetime.timedelta(minutes=10),
            'tick_duration': 60,
            'current_tick': 3
        }

        sleep_seconds = controller.get_sleep_seconds(control_info,
                                                     self.metrics, now)
        self.assertEqual(sleep_seconds, 40)
Exemplo n.º 2
0
    def test_late(self):
        now = datetime.datetime.now(datetime.timezone.utc)
        control_info = {
            'start': now - datetime.timedelta(seconds=200),
            'end': now + datetime.timedelta(minutes=10),
            'tick_duration': 60,
            # We should already be in tick 3
            'current_tick': 2
        }

        sleep_seconds = controller.get_sleep_seconds(control_info,
                                                     self.metrics, now)
        self.assertEqual(sleep_seconds, 0)