Linting + fix tests

This commit is contained in:
zandercymatics 2023-11-22 14:00:06 -07:00
parent 1d70c5058a
commit bcf5c6bc5b
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 9 additions and 4 deletions

View file

@ -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)
return HttpResponse("File not found", status=404)

View file

@ -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):