From 3bd3049fd403886a9653aa7c2fbd1639926420ea Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 21 Jun 2022 12:28:02 +0300 Subject: Test the progress indication feature --- tests/qc_app/test_parse.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'tests/qc_app/test_parse.py') diff --git a/tests/qc_app/test_parse.py b/tests/qc_app/test_parse.py index 46b45d9..a4bfdd5 100644 --- a/tests/qc_app/test_parse.py +++ b/tests/qc_app/test_parse.py @@ -6,11 +6,8 @@ import pytest from qc_app.jobs import job from tests.conftest import uploadable_file_object -def module_uuid4(): - "module patch for the `uuid.uuid4()` function" - return "934c55d8-396e-4959-90e1-2698e9205758" - -def test_parse_with_existing_uploaded_file(client, redis_url, monkeypatch): +def test_parse_with_existing_uploaded_file( + client, redis_url, job_id, monkeypatch): """ GIVEN: 1. A flask application testing client 2. A valid file, and filetype @@ -19,7 +16,7 @@ def test_parse_with_existing_uploaded_file(client, redis_url, monkeypatch): 1. the system redirects to the job/parse status page 2. the job is placed on redis for processing """ - monkeypatch.setattr("qc_app.jobs.uuid4", module_uuid4) + monkeypatch.setattr("qc_app.jobs.uuid4", lambda : job_id) # Upload a file filename = "no_data_errors.tsv" filetype = "average" @@ -34,14 +31,14 @@ def test_parse_with_existing_uploaded_file(client, redis_url, monkeypatch): 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, module_uuid4()) + the_job = job(rconn, job_id) - assert the_job["job_id"] == module_uuid4() + assert the_job["job_id"] == job_id assert the_job["filename"] == filename assert the_job["command"] == " ".join([ "python3", "-m", "scripts.worker", filetype, f"{client.application.config['UPLOAD_FOLDER']}/{filename}", redis_url, - module_uuid4()]) + job_id]) @pytest.mark.parametrize( "filename,uri,error_msgs", -- cgit v1.2.3