예제 #1
0
def test_open_time_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.open_time() is None
예제 #2
0
def test_open_time_one_completed_attempt():
    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)
    assert task.open_time() == (attempt_completed_time -
                                task_created_time).total_seconds()
예제 #3
0
def test_open_time_one_attempt_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))
    assert task.open_time() is None
예제 #4
0
def test_open_time_new_task():
    task = Task("1234",
                "some cmd",
                datetime.datetime(2018, 1, 15, 12, 35, 0),
                max_attempts=2)
    assert task.open_time() is None