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 | |
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.
-rw-r--r-- | qc_app/entry.py | 6 | ||||
-rw-r--r-- | tests/test_data/average.tsv.zip | bin | 0 -> 35479706 bytes | |||
-rw-r--r-- | tests/test_data/empty.zip | bin | 0 -> 22 bytes | |||
-rw-r--r-- | tests/test_data/multiple_files.zip | bin | 0 -> 35495094 bytes | |||
-rw-r--r-- | tests/test_data/non_tsv.zip | bin | 0 -> 224 bytes |
5 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, diff --git a/tests/test_data/average.tsv.zip b/tests/test_data/average.tsv.zip Binary files differnew file mode 100644 index 0000000..09dda4e --- /dev/null +++ b/tests/test_data/average.tsv.zip diff --git a/tests/test_data/empty.zip b/tests/test_data/empty.zip Binary files differnew file mode 100644 index 0000000..15cb0ec --- /dev/null +++ b/tests/test_data/empty.zip diff --git a/tests/test_data/multiple_files.zip b/tests/test_data/multiple_files.zip Binary files differnew file mode 100644 index 0000000..5c2d028 --- /dev/null +++ b/tests/test_data/multiple_files.zip diff --git a/tests/test_data/non_tsv.zip b/tests/test_data/non_tsv.zip Binary files differnew file mode 100644 index 0000000..b3787a6 --- /dev/null +++ b/tests/test_data/non_tsv.zip |