mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-06 00:59:41 -04:00
More fixes, removing literal "created" from code.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
@@ -570,8 +570,8 @@ def test_fetch_notification_statuses_for_job(sample_template):
|
||||
)
|
||||
|
||||
assert {x.status: x.count for x in fetch_notification_statuses_for_job(j1.id)} == {
|
||||
"created": 5,
|
||||
"delivered": 2,
|
||||
NotificationStatus.CREATED: 5,
|
||||
NotificationStatus.DELIVERED: 2,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ from app.dao.jobs_dao import (
|
||||
find_jobs_with_missing_rows,
|
||||
find_missing_row_for_job,
|
||||
)
|
||||
from app.enums import JobStatus
|
||||
from app.enums import JobStatus, NotificationStatus
|
||||
from app.models import Job, NotificationType, TemplateType
|
||||
from tests.app.db import (
|
||||
create_job,
|
||||
@@ -31,19 +31,29 @@ from tests.app.db import (
|
||||
def test_should_count_of_statuses_for_notifications_associated_with_job(
|
||||
sample_template, sample_job
|
||||
):
|
||||
create_notification(sample_template, job=sample_job, status="created")
|
||||
create_notification(sample_template, job=sample_job, status="created")
|
||||
create_notification(sample_template, job=sample_job, status="created")
|
||||
create_notification(sample_template, job=sample_job, status="sending")
|
||||
create_notification(sample_template, job=sample_job, status="delivered")
|
||||
create_notification(
|
||||
sample_template, job=sample_job, status=NotificationStatus.CREATED
|
||||
)
|
||||
create_notification(
|
||||
sample_template, job=sample_job, status=NotificationStatus.CREATED
|
||||
)
|
||||
create_notification(
|
||||
sample_template, job=sample_job, status=NotificationStatus.CREATED
|
||||
)
|
||||
create_notification(
|
||||
sample_template, job=sample_job, status=NotificationStatus.SENDING
|
||||
)
|
||||
create_notification(
|
||||
sample_template, job=sample_job, status=NotificationStatus.DELIVERED
|
||||
)
|
||||
|
||||
results = dao_get_notification_outcomes_for_job(
|
||||
sample_template.service_id, sample_job.id
|
||||
)
|
||||
assert {row.status: row.count for row in results} == {
|
||||
"created": 3,
|
||||
"sending": 1,
|
||||
"delivered": 1,
|
||||
NotificationStatus.CREATED: 3,
|
||||
NotificationStatus.SENDING: 1,
|
||||
NotificationStatus.DELIVERED: 1,
|
||||
}
|
||||
|
||||
|
||||
@@ -60,13 +70,13 @@ def test_should_return_notifications_only_for_this_job(sample_template):
|
||||
job_1 = create_job(sample_template)
|
||||
job_2 = create_job(sample_template)
|
||||
|
||||
create_notification(sample_template, job=job_1, status="created")
|
||||
create_notification(sample_template, job=job_2, status="sent")
|
||||
create_notification(sample_template, job=job_1, status=NotificationStatus.CREATED)
|
||||
create_notification(sample_template, job=job_2, status=NotificationStatus.SENT)
|
||||
|
||||
results = dao_get_notification_outcomes_for_job(
|
||||
sample_template.service_id, job_1.id
|
||||
)
|
||||
assert {row.status: row.count for row in results} == {"created": 1}
|
||||
assert {row.status: row.count for row in results} == {NotificationStatus.CREATED: 1}
|
||||
|
||||
|
||||
def test_should_return_notifications_only_for_this_service(
|
||||
|
||||
@@ -1044,9 +1044,9 @@ def test_dao_fetch_todays_stats_for_service_only_includes_today(notify_db_sessio
|
||||
stats = dao_fetch_todays_stats_for_service(template.service_id)
|
||||
|
||||
stats = {row.status: row.count for row in stats}
|
||||
assert stats["delivered"] == 1
|
||||
assert stats["failed"] == 1
|
||||
assert stats["created"] == 1
|
||||
assert stats[NotificationStatus.DELIVERED] == 1
|
||||
assert stats[NotificationStatus.FAILED] == 1
|
||||
assert stats[NotificationStatus.CREATED] == 1
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Need a better way to test variable DST date")
|
||||
@@ -1079,11 +1079,11 @@ def test_dao_fetch_todays_stats_for_service_only_includes_today_when_clocks_spri
|
||||
stats = dao_fetch_todays_stats_for_service(template.service_id)
|
||||
|
||||
stats = {row.status: row.count for row in stats}
|
||||
assert "delivered" not in stats
|
||||
assert stats["failed"] == 1
|
||||
assert stats["created"] == 1
|
||||
assert not stats.get("permanent-failure")
|
||||
assert not stats.get("temporary-failure")
|
||||
assert NotificationStatus.DELIVERED not in stats
|
||||
assert stats[NotificationStatus.FAILED] == 1
|
||||
assert stats[NotificationStatus.CREATED] == 1
|
||||
assert not stats.get(NotificationStatus.PERMANENT_FAILURE)
|
||||
assert not stats.get(NotificationStatus.TEMPORARY_FAILURE)
|
||||
|
||||
|
||||
def test_dao_fetch_todays_stats_for_service_only_includes_today_during_bst(
|
||||
@@ -1109,10 +1109,10 @@ def test_dao_fetch_todays_stats_for_service_only_includes_today_during_bst(
|
||||
stats = dao_fetch_todays_stats_for_service(template.service_id)
|
||||
|
||||
stats = {row.status: row.count for row in stats}
|
||||
assert "delivered" not in stats
|
||||
assert stats["failed"] == 1
|
||||
assert stats["created"] == 1
|
||||
assert not stats.get("permanent-failure")
|
||||
assert NotificationStatus.DELIVERED not in stats
|
||||
assert stats[NotificationStatus.FAILED] == 1
|
||||
assert stats[NotificationStatus.CREATED] == 1
|
||||
assert not stats.get(NotificationStatus.PERMANENT_FAILURE)
|
||||
|
||||
|
||||
def test_dao_fetch_todays_stats_for_service_only_includes_today_when_clocks_fall_back(
|
||||
@@ -1139,10 +1139,10 @@ def test_dao_fetch_todays_stats_for_service_only_includes_today_when_clocks_fall
|
||||
stats = dao_fetch_todays_stats_for_service(template.service_id)
|
||||
|
||||
stats = {row.status: row.count for row in stats}
|
||||
assert "delivered" not in stats
|
||||
assert stats["failed"] == 1
|
||||
assert stats["created"] == 1
|
||||
assert not stats.get("permanent-failure")
|
||||
assert NotificationStatus.DELIVERED not in stats
|
||||
assert stats[NotificationStatus.FAILED] == 1
|
||||
assert stats[NotificationStatus.CREATED] == 1
|
||||
assert not stats.get(NotificationStatus.PERMANENT_FAILURE)
|
||||
|
||||
|
||||
def test_dao_fetch_todays_stats_for_service_only_includes_during_utc(notify_db_session):
|
||||
@@ -1167,10 +1167,10 @@ def test_dao_fetch_todays_stats_for_service_only_includes_during_utc(notify_db_s
|
||||
stats = dao_fetch_todays_stats_for_service(template.service_id)
|
||||
|
||||
stats = {row.status: row.count for row in stats}
|
||||
assert "delivered" not in stats
|
||||
assert stats["failed"] == 1
|
||||
assert stats["created"] == 1
|
||||
assert not stats.get("permanent-failure")
|
||||
assert NotificationStatus.DELIVERED not in stats
|
||||
assert stats[NotificationStatus.FAILED] == 1
|
||||
assert stats[NotificationStatus.CREATED] == 1
|
||||
assert not stats.get(NotificationStatus.PERMANENT_FAILURE)
|
||||
|
||||
|
||||
def test_dao_fetch_todays_stats_for_all_services_includes_all_services(
|
||||
|
||||
Reference in New Issue
Block a user