Skip to content

Commit

Permalink
test for rest endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jzbahrai committed Feb 9, 2024
1 parent 0b696a9 commit 3b371b4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/service/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down
15 changes: 15 additions & 0 deletions tests/app/service/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
create_user,
save_notification,
)
from tests.conftest import set_config


def test_get_service_list(client, service_factory):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3b371b4

Please sign in to comment.