Refactor python code to address Sonarcloud issues (#900)

- copy/move/delete file class methods now take Path objects as arguments
- The file download endpoint in the Web UI uses the safer download from dir method
- Simplified logging
- Merged nested if statements
- Removed naked handling of unknown error states
- Added fallback empty list for drive_properties, to avoid errors when json file is missing or broken
- Move drive_properties to env[]
- Constants for common error messages
- Dummy variable for list comprehension
This commit is contained in:
Daniel Markstedt
2022-10-09 13:50:20 -07:00
committed by GitHub
parent ca23d9b7a3
commit 1b10b123d2
11 changed files with 105 additions and 154 deletions

View File

@@ -201,7 +201,7 @@ def test_upload_file(http_client, delete_file):
def test_download_file(http_client, create_test_image):
file_name = create_test_image()
response = http_client.post("/files/download", data={"file": f"{IMAGES_DIR}/{file_name}"})
response = http_client.post("/files/download", data={"file": file_name})
assert response.status_code == 200
assert response.headers["content-type"] == "application/octet-stream"