From f323f37ea4fb7b5ed0868d04d6facc36886ff4fd Mon Sep 17 00:00:00 2001 From: mandres2015 Date: Thu, 25 Nov 2021 16:14:52 -0500 Subject: [PATCH] fix: TT-407 problems solved --- V2/tests/api/azure/time_entry_azure_endpoints_test.py | 2 +- V2/tests/integration/daos/time_entries_dao_test.py | 2 +- .../_application/_time_entries/_get_latest_entries.py | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/V2/tests/api/azure/time_entry_azure_endpoints_test.py b/V2/tests/api/azure/time_entry_azure_endpoints_test.py index 782862d2..9a1245f8 100644 --- a/V2/tests/api/azure/time_entry_azure_endpoints_test.py +++ b/V2/tests/api/azure/time_entry_azure_endpoints_test.py @@ -100,7 +100,7 @@ def test__get_latest_entries_azure_endpoint__returns_a_list_of_latest_time_entri assert time_entry_json_data == [inserted_time_entry] -def test__get_latest_entries_azure_endpoint__returns_No_time_entries_found__when_recieve_an_invalid_owner_id( +def test__get_latest_entries_azure_endpoint__returns_no_time_entries_found__when_recieve_an_invalid_owner_id( test_db, insert_activity, activity_factory, ): insert_activity(activity_factory(), test_db) diff --git a/V2/tests/integration/daos/time_entries_dao_test.py b/V2/tests/integration/daos/time_entries_dao_test.py index 26a7beb7..46e2b792 100644 --- a/V2/tests/integration/daos/time_entries_dao_test.py +++ b/V2/tests/integration/daos/time_entries_dao_test.py @@ -86,7 +86,7 @@ def test_get_latest_entries__returns_a_list_of_latest_time_entries__when_an_owne assert result == [inserted_time_entry.__dict__] -def test_get_latest_entries__returns_None__when_an_owner_id_is_not_found( +def test_get_latest_entries__returns_none__when_an_owner_id_is_not_found( create_fake_dao, test_db, insert_activity, activity_factory ): dao = create_fake_dao(test_db) diff --git a/V2/time_tracker/time_entries/_application/_time_entries/_get_latest_entries.py b/V2/time_tracker/time_entries/_application/_time_entries/_get_latest_entries.py index 8c7e8a10..35974c0f 100644 --- a/V2/time_tracker/time_entries/_application/_time_entries/_get_latest_entries.py +++ b/V2/time_tracker/time_entries/_application/_time_entries/_get_latest_entries.py @@ -1,4 +1,5 @@ import json +from http import HTTPStatus import azure.functions as func @@ -20,7 +21,7 @@ def get_latest_entries(req: func.HttpRequest) -> func.HttpResponse: if not owner_id: return func.HttpResponse( body="No owner id found", - status_code=404, + status_code=HTTPStatus.NOT_FOUND, mimetype="application/json" ) @@ -29,19 +30,19 @@ def get_latest_entries(req: func.HttpRequest) -> func.HttpResponse: if not time_entries or len(time_entries) == 0: return func.HttpResponse( body="No time entries found", - status_code=404, + status_code=HTTPStatus.NOT_FOUND, mimetype="application/json" ) return func.HttpResponse( body=json.dumps(time_entries, default=str), - status_code=200, + status_code=HTTPStatus.OK, mimetype="application/json", ) except ValueError: return func.HttpResponse( body=b"Invalid Format ID", - status_code=400, + status_code=HTTPStatus.BAD_REQUEST, mimetype="application/json" )