aboutsummaryrefslogtreecommitdiff
path: root/tests/uploader/test_entry.py
blob: 0c614a59e29747ff0c84c35e65594ec46f3e9f10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""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)