From 3b371b41bc90e022303080b6d335101ad6159be6 Mon Sep 17 00:00:00 2001 From: Jumana Bahrainwala Date: Fri, 9 Feb 2024 18:49:09 +0000 Subject: [PATCH] test for rest endpoint --- app/service/rest.py | 2 +- tests/app/service/test_rest.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/service/rest.py b/app/service/rest.py index a6047148cb..6c7297bfaa 100644 --- a/app/service/rest.py +++ b/app/service/rest.py @@ -216,7 +216,7 @@ def get_live_services_data(): @service_blueprint.route("/delivered-notifications-stats-by-month-data", methods=["GET"]) def get_delivered_notification_stats_by_month_data(): - filter_heartbeats = request.args.get("filter_heartbeats", None) + filter_heartbeats = request.args.get("filter_heartbeats", None) == "True" return jsonify(data=fetch_delivered_notification_stats_by_month(filter_heartbeats=filter_heartbeats)) diff --git a/tests/app/service/test_rest.py b/tests/app/service/test_rest.py index e3e309cda5..c15b2dec6b 100644 --- a/tests/app/service/test_rest.py +++ b/tests/app/service/test_rest.py @@ -70,6 +70,7 @@ create_user, save_notification, ) +from tests.conftest import set_config def test_get_service_list(client, service_factory): @@ -253,6 +254,20 @@ def test_get_delivered_notification_stats_by_month_data(admin_request, sample_se assert first["count"] == 3 +def test_get_delivered_notification_stats_by_month_data_without_heartbeat(notify_api, admin_request, sample_service): + email_template = create_template(service=sample_service, template_type="email", template_name="b") + + create_ft_notification_status( + utc_date=date(2019, 12, 10), + service=sample_service, + template=email_template, + count=3, + ) + with set_config(notify_api, "HEARTBEAT_TEMPLATE_EMAIL_LOW", email_template.id): + response = admin_request.get("service.get_delivered_notification_stats_by_month_data", filter_heartbeats=True)["data"] + assert len(response) == 0 + + def test_get_service_by_id(admin_request, sample_service): json_resp = admin_request.get("service.get_service_by_id", service_id=sample_service.id) assert json_resp["data"]["name"] == sample_service.name