예제 #1
0
def test_is_completed_open_attempt():
    task = Task("1234",
                "some cmd",
                datetime.datetime(2018, 1, 15, 12, 35, 0),
                max_attempts=2)
    attempt_time = datetime.datetime(2018, 1, 15, 12, 35, 30)
    task.attempt_task("runner 1", attempt_time)
    assert task.is_completed() is False
예제 #2
0
def test_is_completed_completed_attempt():
    task = Task("1234",
                "some cmd",
                datetime.datetime(2018, 1, 15, 12, 35, 0),
                max_attempts=2)
    attempt_time = datetime.datetime(2018, 1, 15, 12, 35, 30)
    attempt = task.attempt_task("runner 1", attempt_time)
    attempt.mark_completed(datetime.datetime(2018, 1, 15, 12, 35, 45))
    assert task.is_completed() is True
예제 #3
0
def test_open_time_two_completed_attempts():
    task_created_time = datetime.datetime(2018, 1, 15, 12, 35, 0)
    task = Task("1234", "some cmd", task_created_time, max_attempts=2)
    attempt_time = datetime.datetime(2018, 1, 15, 12, 35, 30)
    attempt = task.attempt_task("runner 1", attempt_time)
    attempt_completed_time = datetime.datetime(2018, 1, 15, 12, 35, 45)
    attempt.mark_completed(attempt_completed_time)
    attempt_time_2 = datetime.datetime(2018, 1, 15, 12, 35, 45)
    attempt_2 = task.attempt_task("runner 2", attempt_time_2)
    attempt_2.mark_completed(datetime.datetime(2018, 1, 15, 12, 35, 48))
    assert task.is_completed() is True
예제 #4
0
def test_is_completed_all_attempts_failed():
    task = Task("1234",
                "some cmd",
                datetime.datetime(2018, 1, 15, 12, 35, 0),
                max_attempts=2)
    attempt_time = datetime.datetime(2018, 1, 15, 12, 35, 30)
    attempt = task.attempt_task("runner 1", attempt_time)
    attempt.mark_failed(datetime.datetime(2018, 1, 15, 12, 35, 45))
    attempt_time_2 = datetime.datetime(2018, 1, 15, 12, 35, 45)
    attempt_2 = task.attempt_task("runner 2", attempt_time_2)
    attempt_2.mark_failed(datetime.datetime(2018, 1, 15, 12, 35, 48))
    assert task.is_completed() is False
예제 #5
0
def test_is_completed_no_attempts():
    task = Task("1234",
                "some cmd",
                datetime.datetime(2018, 1, 15, 12, 35, 0),
                max_attempts=2)
    assert task.is_completed() is False