mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
tests n stuff
This commit is contained in:
@@ -8,7 +8,7 @@ from app.dao.jobs_dao import (
|
||||
dao_create_job,
|
||||
dao_update_job,
|
||||
dao_get_jobs_by_service_id,
|
||||
dao_get_scheduled_jobs,
|
||||
dao_set_scheduled_jobs_to_pending,
|
||||
dao_get_future_scheduled_job_by_id_and_service_id,
|
||||
dao_get_notification_outcomes_for_job,
|
||||
dao_get_jobs_older_than
|
||||
@@ -223,31 +223,42 @@ def test_update_job(sample_job):
|
||||
assert job_from_db.job_status == 'in progress'
|
||||
|
||||
|
||||
def test_get_scheduled_jobs_gets_all_jobs_in_scheduled_state_scheduled_before_now(notify_db, notify_db_session):
|
||||
def test_set_scheduled_jobs_to_pending_gets_all_jobs_in_scheduled_state_before_now(notify_db, notify_db_session):
|
||||
one_minute_ago = datetime.utcnow() - timedelta(minutes=1)
|
||||
one_hour_ago = datetime.utcnow() - timedelta(minutes=60)
|
||||
job_new = create_job(notify_db, notify_db_session, scheduled_for=one_minute_ago, job_status='scheduled')
|
||||
job_old = create_job(notify_db, notify_db_session, scheduled_for=one_hour_ago, job_status='scheduled')
|
||||
jobs = dao_get_scheduled_jobs()
|
||||
jobs = dao_set_scheduled_jobs_to_pending()
|
||||
assert len(jobs) == 2
|
||||
assert jobs[0].id == job_old.id
|
||||
assert jobs[1].id == job_new.id
|
||||
|
||||
|
||||
def test_get_scheduled_jobs_gets_ignores_jobs_not_scheduled(notify_db, notify_db_session):
|
||||
def test_set_scheduled_jobs_to_pending_gets_ignores_jobs_not_scheduled(notify_db, notify_db_session):
|
||||
one_minute_ago = datetime.utcnow() - timedelta(minutes=1)
|
||||
create_job(notify_db, notify_db_session)
|
||||
job_scheduled = create_job(notify_db, notify_db_session, scheduled_for=one_minute_ago, job_status='scheduled')
|
||||
jobs = dao_get_scheduled_jobs()
|
||||
jobs = dao_set_scheduled_jobs_to_pending()
|
||||
assert len(jobs) == 1
|
||||
assert jobs[0].id == job_scheduled.id
|
||||
|
||||
|
||||
def test_get_scheduled_jobs_gets_ignores_jobs_scheduled_in_the_future(sample_scheduled_job):
|
||||
jobs = dao_get_scheduled_jobs()
|
||||
def test_set_scheduled_jobs_to_pending_gets_ignores_jobs_scheduled_in_the_future(sample_scheduled_job):
|
||||
jobs = dao_set_scheduled_jobs_to_pending()
|
||||
assert len(jobs) == 0
|
||||
|
||||
|
||||
def test_set_scheduled_jobs_to_pending_updates_rows(notify_db, notify_db_session):
|
||||
one_minute_ago = datetime.utcnow() - timedelta(minutes=1)
|
||||
one_hour_ago = datetime.utcnow() - timedelta(minutes=60)
|
||||
create_job(notify_db, notify_db_session, scheduled_for=one_minute_ago, job_status='scheduled')
|
||||
create_job(notify_db, notify_db_session, scheduled_for=one_hour_ago, job_status='scheduled')
|
||||
jobs = dao_set_scheduled_jobs_to_pending()
|
||||
assert len(jobs) == 2
|
||||
assert jobs[0].job_status == 'pending'
|
||||
assert jobs[1].job_status == 'pending'
|
||||
|
||||
|
||||
def test_get_future_scheduled_job_gets_a_job_yet_to_send(sample_scheduled_job):
|
||||
result = dao_get_future_scheduled_job_by_id_and_service_id(sample_scheduled_job.id, sample_scheduled_job.service_id)
|
||||
assert result.id == sample_scheduled_job.id
|
||||
|
||||
Reference in New Issue
Block a user