diff options
author | Frederick Muriuki Muriithi | 2024-01-24 12:29:10 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-01-24 12:29:10 +0300 |
commit | 07deef46a3f3ba53cc632a9381fb25c55e1017b1 (patch) | |
tree | a2f4fd1c9f9f69ed774ceff7d0cc5549f630bf9e /tests/qc_app | |
parent | 96c600723726c3391532d86d17183bea960ece57 (diff) | |
download | gn-uploader-07deef46a3f3ba53cc632a9381fb25c55e1017b1.tar.gz |
Checks: Update code and tests to ensure all checks pass.
Diffstat (limited to 'tests/qc_app')
-rw-r--r-- | tests/qc_app/test_entry.py | 3 | ||||
-rw-r--r-- | tests/qc_app/test_parse.py | 28 | ||||
-rw-r--r-- | tests/qc_app/test_uploads_with_zip_files.py | 3 |
3 files changed, 23 insertions, 11 deletions
diff --git a/tests/qc_app/test_entry.py b/tests/qc_app/test_entry.py index c0be26c..efc72a5 100644 --- a/tests/qc_app/test_entry.py +++ b/tests/qc_app/test_entry.py @@ -54,6 +54,7 @@ def test_post_with_correct_data(client): """ response = client.post( "/", data={ + "speciesid": 1, "filetype": "average", "qc_text_file": uploadable_file_object("no_data_errors.tsv") }) @@ -61,7 +62,7 @@ def test_post_with_correct_data(client): assert response.status_code == 302 assert b'Redirecting...' in response.data assert ( - b'/parse/parse?filename=no_data_errors.tsv&filetype=average' + b'/parse/parse?speciesid=1&filename=no_data_errors.tsv&filetype=average' in response.data) @pytest.mark.parametrize( diff --git a/tests/qc_app/test_parse.py b/tests/qc_app/test_parse.py index f173e0a..5e55688 100644 --- a/tests/qc_app/test_parse.py +++ b/tests/qc_app/test_parse.py @@ -4,11 +4,18 @@ import sys import redis import pytest -from qc_app.jobs import job +from qc_app.jobs import job, jobsnamespace + from tests.conftest import uploadable_file_object -def test_parse_with_existing_uploaded_file( - client, redis_url, job_id, monkeypatch): +def test_parse_with_existing_uploaded_file(#pylint: disable=[too-many-arguments] + client, + db_url, + redis_url, + redis_ttl, + jobs_prefix, + job_id, + monkeypatch): """ GIVEN: 1. A flask application testing client 2. A valid file, and filetype @@ -19,27 +26,30 @@ def test_parse_with_existing_uploaded_file( """ monkeypatch.setattr("qc_app.jobs.uuid4", lambda : job_id) # Upload a file + speciesid = 1 filename = "no_data_errors.tsv" filetype = "average" client.post( "/", data={ + "speciesid": speciesid, "filetype": filetype, "qc_text_file": uploadable_file_object(filename)}) # Checks - resp = client.get(f"/parse/parse?filename={filename}&filetype={filetype}") + resp = client.get(f"/parse/parse?speciesid={speciesid}&filename={filename}" + f"&filetype={filetype}") assert resp.status_code == 302 assert b'Redirecting...' in resp.data assert b'/parse/status/934c55d8-396e-4959-90e1-2698e9205758' in resp.data with redis.Redis.from_url(redis_url, decode_responses=True) as rconn: - the_job = job(rconn, job_id) + the_job = job(rconn, jobsnamespace(), job_id) - assert the_job["job_id"] == job_id + assert the_job["jobid"] == job_id assert the_job["filename"] == filename assert the_job["command"] == " ".join([ - sys.executable, "-m", "scripts.validate_file", filetype, - f"{client.application.config['UPLOAD_FOLDER']}/{filename}", redis_url, - job_id]) + sys.executable, "-m", "scripts.validate_file", db_url, redis_url, + jobs_prefix, job_id, "--redisexpiry", str(redis_ttl), str(speciesid), + filetype, f"{client.application.config['UPLOAD_FOLDER']}/{filename}"]) @pytest.mark.parametrize( "filename,uri,error_msgs", diff --git a/tests/qc_app/test_uploads_with_zip_files.py b/tests/qc_app/test_uploads_with_zip_files.py index 2a43a2d..fb101ad 100644 --- a/tests/qc_app/test_uploads_with_zip_files.py +++ b/tests/qc_app/test_uploads_with_zip_files.py @@ -36,12 +36,13 @@ def test_upload_zipfile_with_one_tsv_file(client): THEN: Ensure that the system redirects to the correct next URL """ resp = client.post("/", data={ + "speciesid": 1, "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" + b"/parse/parse?speciesid=1&filename=average.tsv.zip&filetype=average" in resp.data) def test_upload_zipfile_with_one_non_tsv_file(client): |