From 6760d322637a3d875242a66e9c1a784866d7df1d Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 15 Jun 2022 08:05:11 +0300 Subject: Setup test fixtures and initial tests for web-UI --- tests/qc_app/test_entry.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/qc_app/test_entry.py (limited to 'tests/qc_app/test_entry.py') diff --git a/tests/qc_app/test_entry.py b/tests/qc_app/test_entry.py new file mode 100644 index 0000000..d2908ee --- /dev/null +++ b/tests/qc_app/test_entry.py @@ -0,0 +1,55 @@ +"""Test the entry module in the web-ui""" +import io + +def test_basic_elements_present_in_index_page(client): + """ + GIVEN: A flask application testing client + WHEN: the index page is requested with the "POST" method and no datat + THEN: verify that the response contains error notifications + """ + response = client.get("/") + assert response.status_code == 200 + ## form present + assert b'
' in response.data + ## filetype elements + assert b'select file' in response.data + assert b'Invalid file type provided.' + in response.data) + assert ( + b'No file was uploaded.' + in response.data) + +def test_post_with_correct_data(client): + """ + GIVEN: A flask application testing client + WHEN: the index page is requested with the "POST" method and with the + appropriate data provided + THEN: .... + """ + with open("tests/test_data/no_data_errors.tsv", "br") as test_file: + response = client.post( + "/", data={ + "filetype": "average", + "qc_text_file": (io.BytesIO(test_file.read()), "no_data_errors.tsv") + }) + + assert response.status_code == 302 + assert b'Redirecting...' in response.data + assert ( + b'/parse/parse?filename=no_data_errors.tsv&filetype=average' + in response.data) -- cgit v1.2.3