mirror of
https://github.com/akuker/RASCSI.git
synced 2026-04-24 07:16:46 +00:00
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:
@@ -3,6 +3,7 @@ from conftest import STATUS_SUCCESS, STATUS_ERROR
|
||||
|
||||
# route("/login", methods=["POST"])
|
||||
def test_login_with_valid_credentials(pytestconfig, http_client_unauthenticated):
|
||||
# Note: This test depends on the rascsi group existing and 'username' a member the group
|
||||
response = http_client_unauthenticated.post(
|
||||
"/login",
|
||||
data={
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -42,7 +42,7 @@ def test_show_named_drive_presets(http_client):
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response_data["status"] == STATUS_SUCCESS
|
||||
assert "drive_properties" in response_data["data"]
|
||||
assert "files" in response_data["data"]
|
||||
|
||||
|
||||
# route("/drive/cdrom", methods=["POST"])
|
||||
|
||||
Reference in New Issue
Block a user