mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Fix None type error in last-used endpoint.
This commit is contained in:
@@ -64,4 +64,4 @@ def get_last_used_datetime_for_template(service_id, template_id):
|
|||||||
last_date_used = dao_get_last_date_template_was_used(template_id=template_id,
|
last_date_used = dao_get_last_date_template_was_used(template_id=template_id,
|
||||||
service_id=service_id)
|
service_id=service_id)
|
||||||
|
|
||||||
return jsonify(last_date_used=last_date_used.strftime(DATETIME_FORMAT))
|
return jsonify(last_date_used=last_date_used.strftime(DATETIME_FORMAT) if last_date_used else last_date_used)
|
||||||
|
|||||||
@@ -210,6 +210,17 @@ def test_get_last_used_datetime_for_template(
|
|||||||
assert json_resp['last_date_used'] == date_from_notification.strftime(DATETIME_FORMAT)
|
assert json_resp['last_date_used'] == date_from_notification.strftime(DATETIME_FORMAT)
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_last_used_datetime_for_template_returns_none_if_no_usage_of_template(
|
||||||
|
admin_request, sample_template
|
||||||
|
):
|
||||||
|
json_resp = admin_request.get(
|
||||||
|
'template_statistics.get_last_used_datetime_for_template',
|
||||||
|
service_id=str(sample_template.service_id),
|
||||||
|
template_id=sample_template.id
|
||||||
|
)
|
||||||
|
assert json_resp['last_date_used'] is None
|
||||||
|
|
||||||
|
|
||||||
def test_get_last_used_datetime_for_template_returns_400_if_service_does_not_exist(
|
def test_get_last_used_datetime_for_template_returns_400_if_service_does_not_exist(
|
||||||
admin_request, sample_template
|
admin_request, sample_template
|
||||||
):
|
):
|
||||||
|
|||||||
Reference in New Issue
Block a user