mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-06 16:28:24 -04:00
Use client fixture
This commit is contained in:
@@ -1046,34 +1046,33 @@ def test_get_all_notifications_for_service_in_order(notify_api, notify_db, notif
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_get_all_notifications_for_service_including_ones_made_by_jobs(
|
def test_get_all_notifications_for_service_including_ones_made_by_jobs(
|
||||||
notify_api,
|
client,
|
||||||
notify_db,
|
notify_db,
|
||||||
notify_db_session,
|
notify_db_session,
|
||||||
sample_service,
|
sample_service,
|
||||||
include_from_test_key,
|
include_from_test_key,
|
||||||
expected_count_of_notifications
|
expected_count_of_notifications
|
||||||
):
|
):
|
||||||
with notify_api.test_request_context(), notify_api.test_client() as client:
|
with_job = sample_notification_with_job(notify_db, notify_db_session, service=sample_service)
|
||||||
with_job = sample_notification_with_job(notify_db, notify_db_session, service=sample_service)
|
without_job = create_sample_notification(notify_db, notify_db_session, service=sample_service)
|
||||||
without_job = create_sample_notification(notify_db, notify_db_session, service=sample_service)
|
from_test_api_key = create_sample_notification(
|
||||||
from_test_api_key = create_sample_notification(
|
notify_db, notify_db_session, service=sample_service, key_type=KEY_TYPE_TEST
|
||||||
notify_db, notify_db_session, service=sample_service, key_type=KEY_TYPE_TEST
|
)
|
||||||
)
|
|
||||||
|
|
||||||
auth_header = create_authorization_header()
|
auth_header = create_authorization_header()
|
||||||
|
|
||||||
response = client.get(
|
response = client.get(
|
||||||
path='/service/{}/notifications?include_from_test_key={}'.format(
|
path='/service/{}/notifications?include_from_test_key={}'.format(
|
||||||
sample_service.id, include_from_test_key
|
sample_service.id, include_from_test_key
|
||||||
),
|
),
|
||||||
headers=[auth_header]
|
headers=[auth_header]
|
||||||
)
|
)
|
||||||
|
|
||||||
resp = json.loads(response.get_data(as_text=True))
|
resp = json.loads(response.get_data(as_text=True))
|
||||||
assert len(resp['notifications']) == expected_count_of_notifications
|
assert len(resp['notifications']) == expected_count_of_notifications
|
||||||
assert resp['notifications'][0]['to'] == with_job.to
|
assert resp['notifications'][0]['to'] == with_job.to
|
||||||
assert resp['notifications'][1]['to'] == without_job.to
|
assert resp['notifications'][1]['to'] == without_job.to
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
def test_get_only_api_created_notifications_for_service(
|
def test_get_only_api_created_notifications_for_service(
|
||||||
|
|||||||
Reference in New Issue
Block a user