def test_started_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_started() is True
def test_started_one_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_started() is True
def test_started_both_failed_attempts(): 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_started() is True
def test_started_new_task(): task = Task("1234", "some cmd", datetime.datetime(2018, 1, 15, 12, 35, 0), max_attempts=2) assert task.is_started() is False