Beispiel #1
0
def test_allow_execute_flow():
    FlowItem.delete().where(FlowItem.name == FLOW_NAME).execute()

    worktime = pendulum.datetime(2020, 1, 6, tz="Europe/Moscow")
    interval_timedelta = dt.timedelta(1)
    worktime_list = iter_range_datetime(
        start_time=worktime - dt.timedelta(3),
        end_time=worktime,
        timedelta=interval_timedelta,
    )

    FlowItem.create_items(
        flow_name=FLOW_NAME,
        worktime_list=worktime_list,
        status=Statuses.fatal_error,
        notebook_hash="",
    )
    assert (FlowItem.allow_execute_flow(
        FLOW_NAME, notebook_hash="", max_fatal_errors=3) is False)
    assert (FlowItem.allow_execute_flow(
        FLOW_NAME, notebook_hash="new", max_fatal_errors=3) is True)

    FlowItem.recreate_prev_items(
        flow_name=FLOW_NAME,
        worktime=worktime,
        offset_periods=10,
        interval_timedelta=interval_timedelta,
    )
    assert (FlowItem.allow_execute_flow(
        FLOW_NAME, notebook_hash="", max_fatal_errors=3) is True)
Beispiel #2
0
def test_items_for_execute_seconds_interval_without_keep_sequence(
        flowitem_model):
    worktime = pendulum.datetime(2020, 1, 1, tz="Europe/Moscow")

    FlowItem.create_items(flowitem_model.name_for_test,
                          worktime_list=[worktime - dt.timedelta(minutes=4)],
                          **{flowitem_model.status.name: Statuses.success})

    items = FlowItem.get_items_for_execute(
        flow_name=flowitem_model.name_for_test,
        worktime=worktime,
        start_time=worktime - dt.timedelta(minutes=10),
        interval_timedelta=dt.timedelta(minutes=1),
        keep_sequence=False,
        retries=0,
        retry_delay=0,
        notebook_hash="",
        max_fatal_errors=3,
    )

    assert len(items) == 1