mirror of
https://github.com/akuker/RASCSI.git
synced 2026-04-21 18:17:07 +00:00
Web UI: Rework the Attach Device section to be universal (#1393)
* Correct German translation for Key * Web UI: Rework the Attach Device section to be universal * Web UI: Warn when working dirs are missing * Refactor tests to use global endpoint constants * Add fallback for unknown disk type devices * Rearrange the index page sections * Move Macproxy help text to admins page * Remove image list exception for SCHD * Show Settings button when auth is diabled * Tweak CSS styles for both themes * Move Eject action next to the file name, and improve UI labels
This commit is contained in:
@@ -5,16 +5,26 @@ import os
|
||||
from conftest import (
|
||||
FILE_SIZE_1_MIB,
|
||||
STATUS_SUCCESS,
|
||||
CREATE_ENDPOINT,
|
||||
RENAME_ENDPOINT,
|
||||
COPY_ENDPOINT,
|
||||
DELETE_ENDPOINT,
|
||||
DOWNLOAD_URL_ENDPOINT,
|
||||
DOWNLOAD_IMAGE_ENDPOINT,
|
||||
DOWNLOAD_CONFIG_ENDPOINT,
|
||||
EXTRACT_IMAGE_ENDPOINT,
|
||||
UPLOAD_ENDPOINT,
|
||||
CREATE_ISO_ENDPOINT,
|
||||
DISKINFO_ENDPOINT,
|
||||
)
|
||||
|
||||
|
||||
# route("/files/create", methods=["POST"])
|
||||
def test_create_file(http_client, list_files, delete_file):
|
||||
file_prefix = str(uuid.uuid4())
|
||||
file_name = f"{file_prefix}.hds"
|
||||
|
||||
response = http_client.post(
|
||||
"/files/create",
|
||||
CREATE_ENDPOINT,
|
||||
data={
|
||||
"file_name": file_prefix,
|
||||
"type": "hds",
|
||||
@@ -34,13 +44,12 @@ def test_create_file(http_client, list_files, delete_file):
|
||||
delete_file(file_name)
|
||||
|
||||
|
||||
# route("/files/create", methods=["POST"])
|
||||
def test_create_file_with_properties(http_client, list_files, delete_file):
|
||||
file_prefix = str(uuid.uuid4())
|
||||
file_name = f"{file_prefix}.hds"
|
||||
|
||||
response = http_client.post(
|
||||
"/files/create",
|
||||
CREATE_ENDPOINT,
|
||||
data={
|
||||
"file_name": file_prefix,
|
||||
"type": "hds",
|
||||
@@ -64,13 +73,12 @@ def test_create_file_with_properties(http_client, list_files, delete_file):
|
||||
delete_file(file_name)
|
||||
|
||||
|
||||
# route("/files/create", methods=["POST"])
|
||||
def test_create_file_and_format_hfs(http_client, list_files, delete_file):
|
||||
file_prefix = str(uuid.uuid4())
|
||||
file_name = f"{file_prefix}.hda"
|
||||
|
||||
response = http_client.post(
|
||||
"/files/create",
|
||||
CREATE_ENDPOINT,
|
||||
data={
|
||||
"file_name": file_prefix,
|
||||
"type": "hda",
|
||||
@@ -91,7 +99,6 @@ def test_create_file_and_format_hfs(http_client, list_files, delete_file):
|
||||
delete_file(file_name)
|
||||
|
||||
|
||||
# route("/files/create", methods=["POST"])
|
||||
def test_create_file_and_format_fat(env, http_client, list_files, delete_file):
|
||||
if env["is_docker"]:
|
||||
pytest.skip("Test not supported in Docker environment.")
|
||||
@@ -99,7 +106,7 @@ def test_create_file_and_format_fat(env, http_client, list_files, delete_file):
|
||||
file_name = f"{file_prefix}.hdr"
|
||||
|
||||
response = http_client.post(
|
||||
"/files/create",
|
||||
CREATE_ENDPOINT,
|
||||
data={
|
||||
"file_name": file_prefix,
|
||||
"type": "hdr",
|
||||
@@ -120,13 +127,12 @@ def test_create_file_and_format_fat(env, http_client, list_files, delete_file):
|
||||
delete_file(file_name)
|
||||
|
||||
|
||||
# route("/files/rename", methods=["POST"])
|
||||
def test_rename_file(http_client, create_test_image, list_files, delete_file):
|
||||
original_file = create_test_image(auto_delete=False)
|
||||
renamed_file = f"{uuid.uuid4()}.rename"
|
||||
|
||||
response = http_client.post(
|
||||
"/files/rename",
|
||||
RENAME_ENDPOINT,
|
||||
data={"file_name": original_file, "new_file_name": renamed_file},
|
||||
)
|
||||
|
||||
@@ -141,13 +147,12 @@ def test_rename_file(http_client, create_test_image, list_files, delete_file):
|
||||
delete_file(renamed_file)
|
||||
|
||||
|
||||
# route("/files/copy", methods=["POST"])
|
||||
def test_copy_file(http_client, create_test_image, list_files, delete_file):
|
||||
original_file = create_test_image()
|
||||
copy_file = f"{uuid.uuid4()}.copy"
|
||||
|
||||
response = http_client.post(
|
||||
"/files/copy",
|
||||
COPY_ENDPOINT,
|
||||
data={
|
||||
"file_name": original_file,
|
||||
"copy_file_name": copy_file,
|
||||
@@ -167,11 +172,10 @@ def test_copy_file(http_client, create_test_image, list_files, delete_file):
|
||||
delete_file(copy_file)
|
||||
|
||||
|
||||
# route("/files/delete", methods=["POST"])
|
||||
def test_delete_file(http_client, create_test_image, list_files):
|
||||
file_name = create_test_image(auto_delete=False)
|
||||
|
||||
response = http_client.post("/files/delete", data={"file_name": file_name})
|
||||
response = http_client.post(DELETE_ENDPOINT, data={"file_name": file_name})
|
||||
|
||||
response_data = response.json()
|
||||
|
||||
@@ -181,7 +185,6 @@ def test_delete_file(http_client, create_test_image, list_files):
|
||||
assert file_name not in list_files()
|
||||
|
||||
|
||||
# route("/files/extract_image", methods=["POST"])
|
||||
@pytest.mark.parametrize(
|
||||
"archive_file_name,image_file_name",
|
||||
[
|
||||
@@ -205,7 +208,7 @@ def test_extract_file(
|
||||
)
|
||||
|
||||
http_client.post(
|
||||
"/files/download_url",
|
||||
DOWNLOAD_URL_ENDPOINT,
|
||||
data={
|
||||
"destination": "disk_images",
|
||||
"images_subdir": "",
|
||||
@@ -214,7 +217,7 @@ def test_extract_file(
|
||||
)
|
||||
|
||||
response = http_client.post(
|
||||
"/files/extract_image",
|
||||
EXTRACT_IMAGE_ENDPOINT,
|
||||
data={
|
||||
"archive_file": archive_file_name,
|
||||
"archive_members": image_file_name,
|
||||
@@ -233,7 +236,6 @@ def test_extract_file(
|
||||
delete_file(image_file_name)
|
||||
|
||||
|
||||
# route("/files/upload", methods=["POST"])
|
||||
def test_upload_file(http_client, delete_file):
|
||||
file_name = f"{uuid.uuid4()}.test"
|
||||
|
||||
@@ -267,7 +269,7 @@ def test_upload_file(http_client, delete_file):
|
||||
file_data = {"file": (file_name, file.read(chunk_size))}
|
||||
|
||||
response = http_client.post(
|
||||
"/files/upload",
|
||||
UPLOAD_ENDPOINT,
|
||||
data=form_data,
|
||||
files=file_data,
|
||||
)
|
||||
@@ -283,11 +285,10 @@ def test_upload_file(http_client, delete_file):
|
||||
delete_file(file_name)
|
||||
|
||||
|
||||
# route("/files/download_image", methods=["POST"])
|
||||
def test_download_image(http_client, create_test_image):
|
||||
file_name = create_test_image()
|
||||
|
||||
response = http_client.post("/files/download_image", data={"file": file_name})
|
||||
response = http_client.post(DOWNLOAD_IMAGE_ENDPOINT, data={"file": file_name})
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.headers["content-type"] == "application/octet-stream"
|
||||
@@ -295,13 +296,12 @@ def test_download_image(http_client, create_test_image):
|
||||
assert response.headers["content-length"] == str(FILE_SIZE_1_MIB)
|
||||
|
||||
|
||||
# route("/files/download_config", methods=["POST"])
|
||||
def test_download_properties(http_client, list_files, delete_file):
|
||||
file_prefix = str(uuid.uuid4())
|
||||
file_name = f"{file_prefix}.hds"
|
||||
|
||||
response = http_client.post(
|
||||
"/files/create",
|
||||
CREATE_ENDPOINT,
|
||||
data={
|
||||
"file_name": file_prefix,
|
||||
"type": "hds",
|
||||
@@ -321,7 +321,7 @@ def test_download_properties(http_client, list_files, delete_file):
|
||||
)
|
||||
assert file_name in list_files()
|
||||
|
||||
response = http_client.post("/files/download_config", data={"file": f"{file_name}.properties"})
|
||||
response = http_client.post(DOWNLOAD_CONFIG_ENDPOINT, data={"file": f"{file_name}.properties"})
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.headers["content-type"] == "application/octet-stream"
|
||||
@@ -331,7 +331,6 @@ def test_download_properties(http_client, list_files, delete_file):
|
||||
delete_file(file_name)
|
||||
|
||||
|
||||
# route("/files/download_url", methods=["POST"])
|
||||
def test_download_url_to_dir(env, httpserver, http_client, list_files, delete_file):
|
||||
file_name = str(uuid.uuid4())
|
||||
http_path = f"/images/{file_name}"
|
||||
@@ -347,7 +346,7 @@ def test_download_url_to_dir(env, httpserver, http_client, list_files, delete_fi
|
||||
)
|
||||
|
||||
response = http_client.post(
|
||||
"/files/download_url",
|
||||
DOWNLOAD_URL_ENDPOINT,
|
||||
data={
|
||||
"destination": "disk_images",
|
||||
"images_subdir": subdir,
|
||||
@@ -369,7 +368,6 @@ def test_download_url_to_dir(env, httpserver, http_client, list_files, delete_fi
|
||||
delete_file(file_name)
|
||||
|
||||
|
||||
# route("/files/create_iso", methods=["POST"])
|
||||
def test_create_iso_from_url(
|
||||
httpserver,
|
||||
http_client,
|
||||
@@ -392,7 +390,7 @@ def test_create_iso_from_url(
|
||||
)
|
||||
|
||||
response = http_client.post(
|
||||
"/files/create_iso",
|
||||
CREATE_ISO_ENDPOINT,
|
||||
data={
|
||||
"type": ISO_TYPE,
|
||||
"url": url,
|
||||
@@ -414,7 +412,6 @@ def test_create_iso_from_url(
|
||||
delete_file(iso_file_name)
|
||||
|
||||
|
||||
# route("/files/create_iso", methods=["POST"])
|
||||
def test_create_iso_from_local_file(
|
||||
http_client,
|
||||
create_test_image,
|
||||
@@ -427,7 +424,7 @@ def test_create_iso_from_local_file(
|
||||
ISO_TYPE = "HFS"
|
||||
|
||||
response = http_client.post(
|
||||
"/files/create_iso",
|
||||
CREATE_ISO_ENDPOINT,
|
||||
data={
|
||||
"type": ISO_TYPE,
|
||||
"file": test_file_name,
|
||||
@@ -449,12 +446,11 @@ def test_create_iso_from_local_file(
|
||||
delete_file(iso_file_name)
|
||||
|
||||
|
||||
# route("/files/diskinfo", methods=["POST"])
|
||||
def test_show_diskinfo(http_client, create_test_image):
|
||||
test_image = create_test_image()
|
||||
|
||||
response = http_client.post(
|
||||
"/files/diskinfo",
|
||||
DISKINFO_ENDPOINT,
|
||||
data={
|
||||
"file_name": test_image,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user