"""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)