def test_duration_from_started_finished(utcnow, tmpdir): utcnow.side_effect = [ datetime.datetime(2016, 4, 20, 6, 0), datetime.datetime(2016, 4, 20, 6, 2), ] r = Request(Activity(), 1, dir=str(tmpdir)) r.execute() assert r.duration == 120.0
def test_execute_obeys_retrylimit(tmpdir): Request.MAX_RETRIES = 3 r = Request(Activity(), 1, dir=str(tmpdir)) results = [] for i in range(Request.MAX_RETRIES + 1): r.execute() assert len(r.attempts) == i + 1 r.update_state() results.append(r.state) assert results[0] == State.success assert results[-2] == State.success assert results[-1] == State.retrylimit
def test_execute_catches_errors(tmpdir): r = Request(FailingActivity(), 1, dir=str(tmpdir)) r.execute() assert len(r.attempts) == 1 assert 'activity failing' in r.attempts[0].stderr assert r.attempts[0].returncode != 0
def test_duration_from_activity_duration(tmpdir): r = Request(FixedDurationActivity(), 1, dir=str(tmpdir)) r.execute() assert r.duration == 90