From a87ec5a580a209fa516b2cb623ac6cdc6407b2d9 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 22 Jun 2022 11:09:13 +0300 Subject: Test the results pages --- tests/qc_app/test_results_page.py | 68 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 tests/qc_app/test_results_page.py (limited to 'tests/qc_app') diff --git a/tests/qc_app/test_results_page.py b/tests/qc_app/test_results_page.py new file mode 100644 index 0000000..57f1531 --- /dev/null +++ b/tests/qc_app/test_results_page.py @@ -0,0 +1,68 @@ +"Test results page" + +def test_results_with_stderr_output( + client, job_id, stderr_with_output, # pylint: disable=[unused-argument] + redis_conn_with_in_progress_job_no_errors): # pylint: disable=[unused-argument] + """ + GIVEN: 1. A flask application testing client + 2. A file with content to simulate the stderr output + 3. A sample job to prevent the "No such job" error message + WHEN: The parsing progress page is loaded for a non existing job + THEN: Ensure that the page: + 1. Redirects to a job failure display page + 2. The job failure display page: + a) indicates that this is a worker failure + b) provides some debugging information + """ + # Maybe get rid of the use of a stderr file, and check for actual exceptions + resp = client.get(f"/parse/status/{job_id}", follow_redirects=True) + assert len(resp.history) == 1 + assert b'

Worker Failure

' in resp.data + assert b'

Debugging Information

' in resp.data + assert ( + f"
  • job id: {job_id}
  • ".encode("utf8") + in resp.data) + +def test_results_with_completed_job_no_errors( + client, job_id, stderr_with_no_output, # pylint: disable=[unused-argument] + redis_conn_with_completed_job_no_errors): # pylint: disable=[unused-argument] + """ + GIVEN: 1. A flask application testing client + 2. A redis instance with a completed job, with no errors found in + the file + 3. A file with no contents to simulate no stderr output + WHEN: The parsing progress page is loaded + THEN: Ensure that: + 1. the system redirects to the results page + 2. the results page indicates that there are no errors in the file + being processed + """ + resp = client.get(f"/parse/status/{job_id}", follow_redirects=True) + assert len(resp.history) == 1 + assert ( + b'No errors found in the file' + in resp.data) + +def test_results_with_completed_job_some_errors( + client, job_id, stderr_with_no_output, # pylint: disable=[unused-argument] + redis_conn_with_completed_job_some_errors): # pylint: disable=[unused-argument] + """ + GIVEN: 1. A flask application testing client + 2. A redis instance with a completed job, with some errors found in + the file + 3. A file with no contents to simulate no stderr output + WHEN: The parsing progress page is loaded + THEN: Ensure that: + 1. the system redirects to the results page + 2. the results page displays the errors found + """ + resp = client.get(f"/parse/status/{job_id}", follow_redirects=True) + assert len(resp.history) == 1 + assert ( + b'

    We found the following errors

    ' + in resp.data) + assert b'' in resp.data + assert b'Duplicate Header' in resp.data + assert b'' in resp.data + assert b'Invalid Value' in resp.data + assert b'' in resp.data -- cgit v1.2.3
    Heading 'DupHead' is repeatedInvalid value 'ohMy'