"""Test the entry module in the web-ui""" import pytest @pytest.mark.parametrize( "dataitem,lower", ( # expression data UI elements (b'<h2 class="heading">expression data</h2>', True), (b'<a href="/upload"', False), (b'upload expression data</a>', False), # samples/cases data UI elements (b'<h2 class="heading">samples/cases</h2>', True), (b'<a href="/samples/upload/species"', False), (b'upload samples/cases', True), # R/qtl2 data UI elements (b'<h2 class="heading">r/qtl2 bundles</h2>', True), (b'<a href="/upload/rqtl2/select-species"', False), (b'upload r/qtl2 bundle', True) )) def test_landing_page_has_sections(client, dataitem, lower): """ GIVEN: A flask application testing client WHEN: the index page is requested THEN: ensure the page has the expected UI elements """ resp = client.get("/") assert resp.status_code == 200 assert dataitem in (resp.data.lower() if lower else resp.data) def test_landing_page_fails_with_post(client): """ GIVEN: A flask application testing client WHEN: the index page is requested with the "POST" method THEN: ensure the system fails """ resp = client.post("/") assert resp.status_code == 405 assert ( b'<h1>405: The method is not allowed for the requested URL.</h1>' in resp.data)