mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-08 20:23:34 +02:00
Linting and comments
This commit is contained in:
parent
4594eb7ca3
commit
14355327b2
4 changed files with 18 additions and 7 deletions
|
@ -93,7 +93,7 @@ def available(request, domain=""):
|
||||||
|
|
||||||
@require_http_methods(["GET"])
|
@require_http_methods(["GET"])
|
||||||
@login_not_required
|
@login_not_required
|
||||||
def get_current_full(request, file_path = "migrationdata/current-full.csv"):
|
def get_current_full(request, file_path="migrationdata/current-full.csv"):
|
||||||
# Open the CSV file
|
# Open the CSV file
|
||||||
file_path = "migrationdata/current-full.csv"
|
file_path = "migrationdata/current-full.csv"
|
||||||
return serve_file(file_path)
|
return serve_file(file_path)
|
||||||
|
@ -101,9 +101,10 @@ def get_current_full(request, file_path = "migrationdata/current-full.csv"):
|
||||||
|
|
||||||
@require_http_methods(["GET"])
|
@require_http_methods(["GET"])
|
||||||
@login_not_required
|
@login_not_required
|
||||||
def get_current_federal(request, file_path = "migrationdata/current-federal.csv"):
|
def get_current_federal(request, file_path="migrationdata/current-federal.csv"):
|
||||||
return serve_file(file_path)
|
return serve_file(file_path)
|
||||||
|
|
||||||
|
|
||||||
def serve_file(file_path):
|
def serve_file(file_path):
|
||||||
"""Downloads a file based on a given filepath. Returns a 404 if not found."""
|
"""Downloads a file based on a given filepath. Returns a 404 if not found."""
|
||||||
# TODO - #1403, grab from the S3 instance instead
|
# TODO - #1403, grab from the S3 instance instead
|
||||||
|
@ -112,4 +113,4 @@ def serve_file(file_path):
|
||||||
response = FileResponse(open(file_path, "rb"))
|
response = FileResponse(open(file_path, "rb"))
|
||||||
return response
|
return response
|
||||||
else:
|
else:
|
||||||
return HttpResponse("File not found", status=404)
|
return HttpResponse("File not found", status=404)
|
||||||
|
|
|
@ -15,9 +15,14 @@ class Command(BaseCommand):
|
||||||
def add_arguments(self, parser):
|
def add_arguments(self, parser):
|
||||||
"""Add our two filename arguments."""
|
"""Add our two filename arguments."""
|
||||||
parser.add_argument("--directory", default="migrationdata", help="Desired directory")
|
parser.add_argument("--directory", default="migrationdata", help="Desired directory")
|
||||||
parser.add_argument("--checkpath", default=True, help="Used for test cases")
|
parser.add_argument(
|
||||||
|
"--checkpath",
|
||||||
|
default=True,
|
||||||
|
help="Flag that determines if we do a check for os.path.exists. Used for test cases",
|
||||||
|
)
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
|
"""Grabs the directory then creates current-federal.csv in that directory"""
|
||||||
# Ensures a slash is added
|
# Ensures a slash is added
|
||||||
directory = os.path.join(options.get("directory"), "")
|
directory = os.path.join(options.get("directory"), "")
|
||||||
check_path = options.get("checkpath")
|
check_path = options.get("checkpath")
|
||||||
|
|
|
@ -15,9 +15,14 @@ class Command(BaseCommand):
|
||||||
def add_arguments(self, parser):
|
def add_arguments(self, parser):
|
||||||
"""Add our two filename arguments."""
|
"""Add our two filename arguments."""
|
||||||
parser.add_argument("--directory", default="migrationdata", help="Desired directory")
|
parser.add_argument("--directory", default="migrationdata", help="Desired directory")
|
||||||
parser.add_argument("--checkpath", default=True, help="Used for test cases")
|
parser.add_argument(
|
||||||
|
"--checkpath",
|
||||||
|
default=True,
|
||||||
|
help="Flag that determines if we do a check for os.path.exists. Used for test cases",
|
||||||
|
)
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
|
"""Grabs the directory then creates current-full.csv in that directory"""
|
||||||
# Ensures a slash is added
|
# Ensures a slash is added
|
||||||
directory = os.path.join(options.get("directory"), "")
|
directory = os.path.join(options.get("directory"), "")
|
||||||
check_path = options.get("checkpath")
|
check_path = options.get("checkpath")
|
||||||
|
@ -32,6 +37,6 @@ class Command(BaseCommand):
|
||||||
file_path = os.path.join(directory, "current-full.csv")
|
file_path = os.path.join(directory, "current-full.csv")
|
||||||
with open(file_path, "w") as file:
|
with open(file_path, "w") as file:
|
||||||
csv_export.export_data_full_to_csv(file)
|
csv_export.export_data_full_to_csv(file)
|
||||||
|
|
||||||
if check_path and not os.path.exists(file_path):
|
if check_path and not os.path.exists(file_path):
|
||||||
raise FileNotFoundError(f"Could not find newly created file at '{file_path}'")
|
raise FileNotFoundError(f"Could not find newly created file at '{file_path}'")
|
||||||
|
|
|
@ -152,7 +152,7 @@ class CsvReportsTest(TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(file_content, expected_file_content)
|
self.assertEqual(file_content, expected_file_content)
|
||||||
|
|
||||||
def test_load_full_report(self):
|
def test_load_full_report(self):
|
||||||
"""Tests the current-federal api link"""
|
"""Tests the current-federal api link"""
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue