From bcf5c6bc5b733b695ff5ee331e46235d27440fb6 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Wed, 22 Nov 2023 14:00:06 -0700 Subject: [PATCH] Linting + fix tests --- src/api/views.py | 11 +++++++---- src/registrar/tests/test_url_auth.py | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/api/views.py b/src/api/views.py index 298e5fb8c..a565504df 100644 --- a/src/api/views.py +++ b/src/api/views.py @@ -91,25 +91,28 @@ def available(request, domain=""): except Exception: return JsonResponse({"available": False, "message": DOMAIN_API_MESSAGES["error"]}) + @require_http_methods(["GET"]) @login_not_required def get_current_full(request): # Open the CSV file - file_path = 'migrationdata/current-full.csv' + file_path = "migrationdata/current-full.csv" return serve_file(file_path) + @require_http_methods(["GET"]) @login_not_required def get_current_federal(request): # Open the CSV file - file_path = 'migrationdata/current-federal.csv' + file_path = "migrationdata/current-federal.csv" return serve_file(file_path) + def serve_file(file_path): """Downloads a file based on a given filepath. Returns a 404 if not found.""" if os.path.exists(file_path): # Serve the CSV file - response = FileResponse(open(file_path, 'rb')) + response = FileResponse(open(file_path, "rb")) return response else: - return HttpResponse("File not found", status=404) \ No newline at end of file + return HttpResponse("File not found", status=404) diff --git a/src/registrar/tests/test_url_auth.py b/src/registrar/tests/test_url_auth.py index fe3116147..b1a8b8dc7 100644 --- a/src/registrar/tests/test_url_auth.py +++ b/src/registrar/tests/test_url_auth.py @@ -111,6 +111,8 @@ class TestURLAuth(TestCase): "/openid/callback/login/", "/openid/callback/logout/", "/api/v1/available/whitehouse.gov", + "/api/v1/get-report/current-federal", + "/api/v1/get-report/current-full" ] def assertURLIsProtectedByAuth(self, url):