mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-09 13:59:49 -04:00
Add one_off filter when getting all notifications for a service
Added the option to filter by one_off messages to the DAO function `get_notifications_for_service`. Previously, one-off notifications were not returned - this has changed so that the default is for one-off notifications to be returned. Also simplified the `include_jobs` filter for this function. The DAO function gets used in 3 places - for the V1 and V2 API endpoints, which will now start to return one-off messages. It also gets used by the admin app which needs to pass in `include_one_off=False` to the `get_all_notifications_for_service` where we don't want one-off notifications to show, such as the API message log page.
This commit is contained in:
@@ -957,6 +957,21 @@ def test_should_return_notifications_excluding_jobs_by_default(sample_template,
|
||||
assert exclude_jobs_manually[0].id == without_job.id
|
||||
|
||||
|
||||
def test_should_return_notifications_including_one_offs_by_default(sample_user, sample_template):
|
||||
create_notification(sample_template, one_off=True, created_by_id=sample_user.id)
|
||||
not_one_off = create_notification(sample_template)
|
||||
|
||||
exclude_one_offs = get_notifications_for_service(sample_template.service_id, include_one_off=False).items
|
||||
assert len(exclude_one_offs) == 1
|
||||
assert exclude_one_offs[0].id == not_one_off.id
|
||||
|
||||
include_one_offs_manually = get_notifications_for_service(sample_template.service_id, include_one_off=True).items
|
||||
assert len(include_one_offs_manually) == 2
|
||||
|
||||
include_one_offs_by_default = get_notifications_for_service(sample_template.service_id).items
|
||||
assert len(include_one_offs_by_default) == 2
|
||||
|
||||
|
||||
def test_get_notifications_created_by_api_or_csv_are_returned_correctly_excluding_test_key_notifications(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
|
||||
Reference in New Issue
Block a user