mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 23:41:17 -05:00
Combine test to query notifications within date range instead
This commit is contained in:
@@ -12,24 +12,17 @@ from tests.app.conftest import (
|
||||
sample_template
|
||||
)
|
||||
|
||||
|
||||
def test_get_total_notifications_filters_on_date(sample_template):
|
||||
create_notification(sample_template, created_at=datetime(2016, 10, 17, 10, 0))
|
||||
create_notification(sample_template, created_at=datetime(2016, 10, 18, 10, 0))
|
||||
create_notification(sample_template, created_at=datetime(2016, 10, 19, 10, 0))
|
||||
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(date(2016, 10, 18), date(2016, 10, 19))
|
||||
|
||||
assert result.messages_total == 1
|
||||
BEGINNING_OF_DAY = date(2016, 10, 18)
|
||||
END_OF_DAY = date(2016, 10, 19)
|
||||
|
||||
|
||||
def test_get_total_notifications_filters_on_date_at_midnight(sample_template):
|
||||
def test_get_total_notifications_filters_on_date_within_date_range(sample_template):
|
||||
create_notification(sample_template, created_at=datetime(2016, 10, 17, 23, 59, 59))
|
||||
create_notification(sample_template, created_at=datetime(2016, 10, 18, 0, 0))
|
||||
create_notification(sample_template, created_at=BEGINNING_OF_DAY)
|
||||
create_notification(sample_template, created_at=datetime(2016, 10, 18, 23, 59, 59))
|
||||
create_notification(sample_template, created_at=datetime(2016, 10, 19, 0, 0))
|
||||
create_notification(sample_template, created_at=END_OF_DAY)
|
||||
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(date(2016, 10, 18), date(2016, 10, 19))
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(BEGINNING_OF_DAY, END_OF_DAY)
|
||||
|
||||
assert result.messages_total == 2
|
||||
|
||||
@@ -42,7 +35,7 @@ def test_get_total_notifications_only_counts_api_notifications(sample_template,
|
||||
create_notification(sample_template, job=sample_job)
|
||||
create_notification(sample_template, api_key=sample_api_key)
|
||||
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(date(2016, 10, 18), date(2016, 10, 19))
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(BEGINNING_OF_DAY, END_OF_DAY)
|
||||
|
||||
assert result.messages_total == 1
|
||||
|
||||
@@ -57,7 +50,7 @@ def test_get_total_notifications_ignores_test_keys(sample_template):
|
||||
create_notification(sample_template, key_type=KEY_TYPE_TEAM)
|
||||
create_notification(sample_template, key_type=KEY_TYPE_TEST)
|
||||
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(date(2016, 10, 18), date(2016, 10, 19))
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(BEGINNING_OF_DAY, END_OF_DAY)
|
||||
|
||||
assert result.messages_total == 4
|
||||
|
||||
@@ -76,7 +69,7 @@ def test_get_total_notifications_ignores_letters(
|
||||
create_notification(sample_email_template)
|
||||
create_notification(sample_letter_template)
|
||||
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(date(2016, 10, 18), date(2016, 10, 19))
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(BEGINNING_OF_DAY, END_OF_DAY)
|
||||
|
||||
assert result.messages_total == 4
|
||||
|
||||
@@ -89,7 +82,7 @@ def test_get_total_notifications_counts_messages_within_10_seconds(sample_templa
|
||||
create_notification(sample_template, sent_at=created_at + timedelta(seconds=10))
|
||||
create_notification(sample_template, sent_at=created_at + timedelta(seconds=15))
|
||||
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(date(2016, 10, 18), date(2016, 10, 19))
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(BEGINNING_OF_DAY, END_OF_DAY)
|
||||
|
||||
assert result.messages_total == 3
|
||||
assert result.messages_within_10_secs == 2
|
||||
@@ -99,7 +92,7 @@ def test_get_total_notifications_counts_messages_within_10_seconds(sample_templa
|
||||
def test_get_total_notifications_counts_messages_that_have_not_sent(sample_template):
|
||||
create_notification(sample_template, status='created', sent_at=None)
|
||||
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(date(2016, 10, 18), date(2016, 10, 19))
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(BEGINNING_OF_DAY, END_OF_DAY)
|
||||
|
||||
assert result.messages_total == 1
|
||||
assert result.messages_within_10_secs == 0
|
||||
@@ -107,7 +100,7 @@ def test_get_total_notifications_counts_messages_that_have_not_sent(sample_templ
|
||||
|
||||
@freeze_time('2016-10-18T10:00')
|
||||
def test_get_total_notifications_returns_zero_if_no_data(notify_db_session):
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(date(2016, 10, 18), date(2016, 10, 19))
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(BEGINNING_OF_DAY, END_OF_DAY)
|
||||
|
||||
assert result.messages_total == 0
|
||||
assert result.messages_within_10_secs == 0
|
||||
@@ -136,7 +129,7 @@ def test_get_total_notifications_counts_ignores_research_mode(notify_db, notify_
|
||||
sent_at=created_at + timedelta(seconds=5)
|
||||
)
|
||||
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(date(2016, 10, 18), date(2016, 10, 19))
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(BEGINNING_OF_DAY, END_OF_DAY)
|
||||
|
||||
assert result.messages_total == 2
|
||||
assert result.messages_within_10_secs == 2
|
||||
|
||||
Reference in New Issue
Block a user