mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
Renamed some files and fixed a bug on deleting the failed notifications
This commit is contained in:
@@ -51,9 +51,9 @@ def test_should_call_delete_codes_on_delete_verify_codes_task(notify_api, mocker
|
||||
|
||||
|
||||
def test_should_call_delete_invotations_on_delete_invitations_task(notify_api, mocker):
|
||||
mocker.patch('app.celery.tasks.delete_invitations_older_created_more_than_a_day_ago')
|
||||
mocker.patch('app.celery.tasks.delete_invitations_created_more_than_two_days_ago')
|
||||
delete_invitations()
|
||||
assert tasks.delete_invitations_older_created_more_than_a_day_ago.call_count == 1
|
||||
assert tasks.delete_invitations_created_more_than_two_days_ago.call_count == 1
|
||||
|
||||
|
||||
@freeze_time("2016-01-01 11:09:00.061258")
|
||||
|
||||
@@ -9,7 +9,7 @@ from app.dao.invited_user_dao import (
|
||||
get_invited_user,
|
||||
get_invited_users_for_service,
|
||||
get_invited_user_by_id,
|
||||
delete_invitations_older_created_more_than_a_day_ago
|
||||
delete_invitations_created_more_than_two_days_ago
|
||||
)
|
||||
|
||||
|
||||
@@ -91,23 +91,23 @@ def test_save_invited_user_sets_status_to_cancelled(notify_db, notify_db_session
|
||||
def test_should_delete_all_invitations_more_than_one_day_old(
|
||||
sample_user,
|
||||
sample_service):
|
||||
make_invitation(sample_user, sample_service, age=timedelta(hours=24))
|
||||
make_invitation(sample_user, sample_service, age=timedelta(hours=24))
|
||||
make_invitation(sample_user, sample_service, age=timedelta(hours=48))
|
||||
make_invitation(sample_user, sample_service, age=timedelta(hours=48))
|
||||
assert len(InvitedUser.query.all()) == 2
|
||||
delete_invitations_older_created_more_than_a_day_ago()
|
||||
delete_invitations_created_more_than_two_days_ago()
|
||||
assert len(InvitedUser.query.all()) == 0
|
||||
|
||||
|
||||
def test_should_not_delete_invitations_less_than_one_day_old(
|
||||
def test_should_not_delete_invitations_less_than_two_days_old(
|
||||
sample_user,
|
||||
sample_service):
|
||||
make_invitation(sample_user, sample_service, age=timedelta(hours=23, minutes=59, seconds=59),
|
||||
make_invitation(sample_user, sample_service, age=timedelta(hours=47, minutes=59, seconds=59),
|
||||
email_address="valid@2.com")
|
||||
make_invitation(sample_user, sample_service, age=timedelta(hours=24),
|
||||
make_invitation(sample_user, sample_service, age=timedelta(hours=48),
|
||||
email_address="expired@1.com")
|
||||
|
||||
assert len(InvitedUser.query.all()) == 2
|
||||
delete_invitations_older_created_more_than_a_day_ago()
|
||||
delete_invitations_created_more_than_two_days_ago()
|
||||
assert len(InvitedUser.query.all()) == 1
|
||||
assert InvitedUser.query.first().email_address == "valid@2.com"
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from datetime import datetime
|
||||
import uuid
|
||||
import app.celery.tasks
|
||||
from tests import create_authorization_header
|
||||
@@ -126,11 +127,16 @@ def test_get_all_notifications_for_job_in_order(notify_api, notify_db, notify_db
|
||||
with notify_api.test_client() as client:
|
||||
main_job = sample_job(notify_db, notify_db_session, service=sample_service)
|
||||
another_job = sample_job(notify_db, notify_db_session, service=sample_service)
|
||||
from time import sleep
|
||||
|
||||
notification_1 = sample_notification(notify_db, notify_db_session, job=main_job, to_field="1")
|
||||
notification_2 = sample_notification(notify_db, notify_db_session, job=main_job, to_field="2")
|
||||
notification_3 = sample_notification(notify_db, notify_db_session, job=main_job, to_field="3")
|
||||
notification_1 = sample_notification(
|
||||
notify_db, notify_db_session, job=main_job, to_field="1", created_at=datetime.utcnow()
|
||||
)
|
||||
notification_2 = sample_notification(
|
||||
notify_db, notify_db_session, job=main_job, to_field="2", created_at=datetime.utcnow()
|
||||
)
|
||||
notification_3 = sample_notification(
|
||||
notify_db, notify_db_session, job=main_job, to_field="3", created_at=datetime.utcnow()
|
||||
)
|
||||
sample_notification(notify_db, notify_db_session, job=another_job)
|
||||
|
||||
auth_header = create_authorization_header(
|
||||
|
||||
Reference in New Issue
Block a user