mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
Add test to check with notificationhistory but no notification
This commit is contained in:
@@ -5,7 +5,12 @@ import pytest
|
||||
from freezegun import freeze_time
|
||||
|
||||
from tests import create_authorization_header
|
||||
from tests.app.conftest import (sample_template as create_sample_template, sample_notification, sample_email_template)
|
||||
from tests.app.conftest import (
|
||||
sample_template as create_sample_template,
|
||||
sample_notification,
|
||||
sample_notification_history,
|
||||
sample_email_template
|
||||
)
|
||||
|
||||
|
||||
def test_get_all_template_statistics_with_bad_arg_returns_400(client, sample_service):
|
||||
@@ -223,7 +228,7 @@ def test_get_template_statistics_for_template_returns_empty_if_no_statistics(
|
||||
|
||||
assert response.status_code == 200
|
||||
json_resp = json.loads(response.get_data(as_text=True))
|
||||
assert json_resp['data'] == {}
|
||||
assert not json_resp['data']
|
||||
|
||||
|
||||
def test_get_template_statistics_raises_error_for_nonexistent_template(
|
||||
@@ -242,3 +247,23 @@ def test_get_template_statistics_raises_error_for_nonexistent_template(
|
||||
json_resp = json.loads(response.get_data(as_text=True))
|
||||
assert json_resp['message'] == 'No result found'
|
||||
assert json_resp['result'] == 'error'
|
||||
|
||||
|
||||
def test_get_template_statistics_by_id_returns_empty_for_old_notification(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
client,
|
||||
sample_template
|
||||
):
|
||||
sample_notification_history(notify_db, notify_db_session, sample_template)
|
||||
|
||||
auth_header = create_authorization_header()
|
||||
|
||||
response = client.get(
|
||||
'/service/{}/template-statistics/{}'.format(sample_template.service.id, sample_template.id),
|
||||
headers=[('Content-Type', 'application/json'), auth_header],
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
json_resp = json.loads(response.get_data(as_text=True))['data']
|
||||
assert not json_resp
|
||||
|
||||
Reference in New Issue
Block a user