Allow the selecting of target dir when uploading or downloading files (#867)

Uses a single endpoint for downloading files
Adds a select field to pick target dir for both download and upload forms
Moves the Macproxy/Netatalk helptext into the helptext blocks, and the related status messages down into the page footer
This commit is contained in:
Daniel Markstedt
2022-09-27 17:38:34 -07:00
committed by GitHub
parent 3ac3abb13f
commit 3c8e7dbef0
3 changed files with 64 additions and 107 deletions

View File

@ -122,8 +122,9 @@ def test_extract_file(
)
http_client.post(
"/files/download_to_images",
"/files/download_url",
data={
"destination": "images",
"url": url,
},
)
@ -200,7 +201,10 @@ 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": f"{IMAGES_DIR}/{file_name}"}
)
assert response.status_code == 200
assert response.headers["content-type"] == "application/octet-stream"
@ -208,36 +212,8 @@ def test_download_file(http_client, create_test_image):
assert response.headers["content-length"] == str(FILE_SIZE_1_MIB)
# route("/files/download_to_afp", methods=["POST"])
def test_download_url_to_afp_dir(httpserver, http_client):
file_name = str(uuid.uuid4())
http_path = f"/images/{file_name}"
url = httpserver.url_for(http_path)
with open("tests/assets/test_image.hds", mode="rb") as file:
file_data = file.read()
httpserver.expect_request(http_path).respond_with_data(
file_data,
mimetype="application/octet-stream",
)
response = http_client.post(
"/files/download_to_afp",
data={
"url": url,
},
)
response_data = response.json()
assert response.status_code == 200
assert response_data["status"] == STATUS_SUCCESS
assert response_data["messages"][0]["message"] == f"{file_name} downloaded to {AFP_DIR}"
# route("/files/download_to_images", methods=["POST"])
def test_download_url_to_images_dir(httpserver, http_client, list_files, delete_file):
# route("/files/download_url", methods=["POST"])
def test_download_url_to_dir(httpserver, http_client, list_files, delete_file):
file_name = str(uuid.uuid4())
http_path = f"/images/{file_name}"
url = httpserver.url_for(http_path)
@ -251,8 +227,9 @@ def test_download_url_to_images_dir(httpserver, http_client, list_files, delete_
)
response = http_client.post(
"/files/download_to_images",
"/files/download_url",
data={
"destination": "images",
"url": url,
},
)