diff options
author | Frederick Muriuki Muriithi | 2022-06-21 03:55:42 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-06-21 03:55:42 +0300 |
commit | 6375b2394eab075af6e7488d343131dc99fd7c3b (patch) | |
tree | f499bb3ae795a3601fad9481733f59b305ae9cac /qc_app | |
parent | d2efffd5fa48fd66084b7e7f4aaeb4c3c8ece58c (diff) | |
download | gn-uploader-6375b2394eab075af6e7488d343131dc99fd7c3b.tar.gz |
Test the upload of zip files works as expected
- Ensure errors respond with status code 400
- Ensure error messages are displayed for any invalid zip file that is
uploaded.
Diffstat (limited to 'qc_app')
-rw-r--r-- | qc_app/entry.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/qc_app/entry.py b/qc_app/entry.py index c53648a..efcaf4e 100644 --- a/qc_app/entry.py +++ b/qc_app/entry.py @@ -55,7 +55,7 @@ def zip_file_errors(filepath, upload_dir) -> Tuple[str, ...]: if len(infolist) != 1: zfile_errors = zfile_errors + ( ("Expected exactly one (1) member file within the uploaded zip " - "file. Got {len(infolist)} member files."),) + f"file. Got {len(infolist)} member files."),) if len(infolist) == 1 and infolist[0].is_dir(): zfile_errors = zfile_errors + ( ("Expected a member text file in the uploaded zip file. Got a " @@ -82,7 +82,7 @@ def upload_file(): if request_errors: for error in request_errors: flash(error, "alert-error") - return render_template("index.html") + return render_template("index.html"), 400 filename = secure_filename(request.files["qc_text_file"].filename) if not os.path.exists(upload_dir): @@ -95,7 +95,7 @@ def upload_file(): if zip_errors: for error in zip_errors: flash(error, "alert-error") - return render_template("index.html") + return render_template("index.html"), 400 return redirect(url_for( "parse.parse", filename=filename, |