mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-01 12:19:47 -04:00
Working functionality for filtering notifications and all tests passing.
This commit is contained in:
@@ -107,6 +107,58 @@ def test_should_show_notifications_for_a_service(app_,
|
||||
assert '.csv' in content
|
||||
|
||||
|
||||
def test_can_view_only_sms_notifications_for_a_service(app_,
|
||||
service_one,
|
||||
api_user_active,
|
||||
mock_login,
|
||||
mock_get_user,
|
||||
mock_get_user_by_email,
|
||||
mock_get_service,
|
||||
mock_get_notifications,
|
||||
mock_has_permissions):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
response = client.get(url_for(
|
||||
'main.view_notifications',
|
||||
service_id=service_one['id'],
|
||||
type='sms'))
|
||||
assert response.status_code == 200
|
||||
content = response.get_data(as_text=True)
|
||||
notifications = mock_get_notifications(service_one['id'])
|
||||
notification = notifications['notifications'][0]
|
||||
assert notification['to'] in content
|
||||
assert notification['status'] in content
|
||||
assert notification['template']['name'] in content
|
||||
assert '.csv' in content
|
||||
|
||||
|
||||
def test_can_view_successful_notifications_for_a_service(app_,
|
||||
service_one,
|
||||
api_user_active,
|
||||
mock_login,
|
||||
mock_get_user,
|
||||
mock_get_user_by_email,
|
||||
mock_get_service,
|
||||
mock_get_notifications,
|
||||
mock_has_permissions):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
response = client.get(url_for(
|
||||
'main.view_notifications',
|
||||
service_id=service_one['id'],
|
||||
status=['sent', 'delivered']))
|
||||
assert response.status_code == 200
|
||||
content = response.get_data(as_text=True)
|
||||
notifications = mock_get_notifications(service_one['id'])
|
||||
notification = notifications['notifications'][0]
|
||||
assert notification['to'] in content
|
||||
assert notification['status'] in content
|
||||
assert notification['template']['name'] in content
|
||||
assert '.csv' in content
|
||||
|
||||
|
||||
def test_should_show_notifications_for_a_service_with_next_previous(app_,
|
||||
service_one,
|
||||
api_user_active,
|
||||
|
||||
@@ -642,7 +642,11 @@ def mock_get_jobs(mocker):
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_notifications(mocker):
|
||||
def _get_notifications(service_id, job_id=None, page=1):
|
||||
def _get_notifications(service_id,
|
||||
job_id=None,
|
||||
page=1,
|
||||
template_type=None,
|
||||
status=None):
|
||||
return notification_json(service_id)
|
||||
return mocker.patch(
|
||||
'app.notification_api_client.get_notifications_for_service',
|
||||
@@ -652,7 +656,11 @@ def mock_get_notifications(mocker):
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_notifications_with_previous_next(mocker):
|
||||
def _get_notifications(service_id, job_id=None, page=1):
|
||||
def _get_notifications(service_id,
|
||||
job_id=None,
|
||||
page=1,
|
||||
template_type=None,
|
||||
status=None):
|
||||
return notification_json(service_id, with_links=True)
|
||||
return mocker.patch(
|
||||
'app.notification_api_client.get_notifications_for_service',
|
||||
|
||||
Reference in New Issue
Block a user