diff options
author | Frederick Muriuki Muriithi | 2022-06-22 11:09:48 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-06-22 11:09:48 +0300 |
commit | 3eef6d582245c80e274c9e135028de90788a712b (patch) | |
tree | f4be51c158055e0ced2695be9c40b56034a8708d /tests/qc_app | |
parent | a87ec5a580a209fa516b2cb623ac6cdc6407b2d9 (diff) | |
download | gn-uploader-3eef6d582245c80e274c9e135028de90788a712b.tar.gz |
Test zipfiles uploads: commit forgotten tests
Diffstat (limited to 'tests/qc_app')
-rw-r--r-- | tests/qc_app/test_uploads_with_zip_files.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/qc_app/test_uploads_with_zip_files.py b/tests/qc_app/test_uploads_with_zip_files.py new file mode 100644 index 0000000..2a43a2d --- /dev/null +++ b/tests/qc_app/test_uploads_with_zip_files.py @@ -0,0 +1,60 @@ +"""Test the upload of zip files""" +from tests.conftest import uploadable_file_object + +def test_upload_zipfile_with_zero_files(client): + """ + GIVEN: A flask application testing client + WHEN: A zip file with no files is uploaded + THEN: Ensure that the system responds with the appropriate error message and + status code + """ + resp = client.post("/", data={ + "filetype": "average", + "qc_text_file": uploadable_file_object("empty.zip")}) + assert resp.status_code == 400 + assert (b"Expected exactly one (1) member file within the uploaded zip " + b"file. Got 0 member files.") in resp.data + +def test_upload_zipfile_with_multiple_files(client): + """ + GIVEN: A flask application testing client + WHEN: A zip file with more than one file is uploaded + THEN: Ensure that the system responds with the appropriate error message and + status code + """ + resp = client.post("/", data={ + "filetype": "average", + "qc_text_file": uploadable_file_object("multiple_files.zip")}) + assert resp.status_code == 400 + assert (b"Expected exactly one (1) member file within the uploaded zip " + b"file. Got 3 member files.") in resp.data + +def test_upload_zipfile_with_one_tsv_file(client): + """ + GIVEN: A flask application testing client + WHEN: A zip file with exactly one valid TSV file is uploaded + THEN: Ensure that the system redirects to the correct next URL + """ + resp = client.post("/", data={ + "filetype": "average", + "qc_text_file": uploadable_file_object("average.tsv.zip")}) + assert resp.status_code == 302 + assert b"Redirecting..." in resp.data + assert ( + b"/parse/parse?filename=average.tsv.zip&filetype=average" + in resp.data) + +def test_upload_zipfile_with_one_non_tsv_file(client): + """ + GIVEN: A flask application testing client + WHEN: A zip file with exactly one file, which is not a valid TSV, is + uploaded + THEN: Ensure that the system responds with the appropriate error message and + status code + """ + resp = client.post("/", data={ + "filetype": "average", + "qc_text_file": uploadable_file_object("non_tsv.zip")}) + assert resp.status_code == 400 + assert (b"Expected the member text file in the uploaded zip file to " + b"be a tab-separated file.") in resp.data |