def test_job_todo_over_two_hours_out(db_session, setup_session): users, aliases, reminders = setup_session for reminder in reminders: out = Reminder.parse_reminder(reminder.id, session=db_session) todo_list = Job.todo(160, session=db_session) assert len(todo_list) == 2 for job in todo_list: assert job.execution_time > datetime.utcnow()
def test_job_create_valid(db_session, setup_session): users, aliases, reminders = setup_session future_reminder = reminders[3] past_jobs = db_session.query(Job).all() job_time = Reminder.get_next_job(future_reminder.id, session=db_session) new_job = Job.create_job(future_reminder.id, job_time, session=db_session) present_jobs = db_session.query(Job).all() assert len(past_jobs) + 1 == len(present_jobs) assert isinstance(new_job, Job)
def test_job_mark_complete_valid(db_session, setup_session): users, aliases, reminders = setup_session future_reminder = reminders[3] job_time = Reminder.get_next_job(future_reminder.id, session=db_session) new_job = Job.create_job(future_reminder.id, job_time, session=db_session) assert new_job.job_state == 0 out = new_job.mark_complete() assert new_job.job_state == 1 assert out is True
def test_job_create_invalid(db_session, setup_session): users, aliases, reminders = setup_session job_time = datetime.utcnow() with pytest.raises(NoResultFound): Job.create_job(1200, job_time, session=db_session)