Skip to content

Commit

Permalink
Remove scalars from execute and add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Shumway committed Nov 7, 2024
1 parent 165042b commit 6df7a21
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/dao/services_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def dao_fetch_stats_for_service_from_days(service_id, start_date, end_date):
func.date_trunc("day", NotificationAllTimeView.created_at),
)
)
return db.session.execute(stmt).scalars().all()
return db.session.execute(stmt).all()


def dao_fetch_stats_for_service_from_days_for_user(
Expand Down
40 changes: 40 additions & 0 deletions tests/app/service/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3634,3 +3634,43 @@ def test_get_monthly_notification_data_by_service(sample_service, admin_request)
0,
],
]


def test_get_service_notification_statistics_by_day(
admin_request, mocker, sample_service
):
mock_data = [
{
"notification_type": "email",
"status": "sent",
"day": "2024-11-01",
"count": 10,
},
{
"notification_type": "sms",
"status": "failed",
"day": "2024-11-02",
"count": 5,
},
{
"notification_type": "sms",
"status": "delivered",
"day": "2024-11-03",
"count": 11,
},
]

mock_get_service_statistics_for_specific_days = mocker.patch(
"app.service.rest.get_service_statistics_for_specific_days",
return_value=mock_data,
)

response = admin_request.get(
"service.get_service_notification_statistics_by_day",
service_id=sample_service.id,
start="2024-11-03",
days="1",
)["data"]

assert mock_get_service_statistics_for_specific_days.assert_called_once
assert response == mock_data

0 comments on commit 6df7a21

Please sign in to comment.