Ejemplo n.º 1
0
    def test_task_run_is_scheduled_in_the_past(self, timing_mocks):
        timing_mocks.get_flow_run_scheduled_start_time.return_value = None
        timing_mocks.get_next_task_run_start_time.return_value = (
            timing_mocks.now().subtract(seconds=10))

        _wait_for_flow_run_start_time("flow-run-id")

        # Did not sleep
        timing_mocks.sleep.assert_not_called()
Ejemplo n.º 2
0
    def test_task_run_is_scheduled_in_the_future(self, timing_mocks):
        timing_mocks.get_flow_run_scheduled_start_time.return_value = None
        timing_mocks.get_next_task_run_start_time.return_value = timing_mocks.now(
        ).add(seconds=10)

        _wait_for_flow_run_start_time("flow-run-id")

        # Slept for the correct interval
        timing_mocks.sleep.assert_called_once_with(10)
Ejemplo n.º 3
0
    def test_flow_and_task_run_are_scheduled_in_the_future(self, timing_mocks):
        timing_mocks.get_flow_run_scheduled_start_time.return_value = (
            timing_mocks.now().add(seconds=10))
        timing_mocks.get_next_task_run_start_time.return_value = timing_mocks.now(
        ).add(seconds=20)

        _wait_for_flow_run_start_time("flow-run-id")

        # Slept for the correct interval in order
        timing_mocks.sleep.assert_has_calls([call(10), call(20)])
Ejemplo n.º 4
0
    def test_flow_run_is_ready_immediately(self, timing_mocks):
        timing_mocks.get_flow_run_scheduled_start_time.return_value = None
        timing_mocks.get_next_task_run_start_time.return_value = None

        _wait_for_flow_run_start_time("flow-run-id")

        # Called timing functions
        timing_mocks.get_flow_run_scheduled_start_time.assert_called_once_with(
            "flow-run-id")
        timing_mocks.get_next_task_run_start_time.assert_called_once_with(
            "flow-run-id")

        # Returned without sleeping
        timing_mocks.sleep.assert_not_called()