-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_gui.py
More file actions
40 lines (30 loc) · 1.07 KB
/
test_gui.py
File metadata and controls
40 lines (30 loc) · 1.07 KB
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
import json
import pytest
from streamlit.testing.v1 import AppTest
# Pages that AppTest.from_file can load in isolation. Pages using st.page_link
# require streamlit's navigation context (only set up when app.py runs), so they
# are covered indirectly by test_app_loads below.
DIRECTLY_TESTABLE_PAGES = [
"content/workflow_fileupload.py",
"content/workflow_configure.py",
"content/workflow_run.py",
"content/results_library.py",
"content/results_proteomicslfq.py",
]
def _init(apptest):
with open("settings.json", "r") as f:
apptest.session_state.settings = json.load(f)
apptest.session_state.settings["test"] = True
apptest.secrets["workspace"] = "test"
return apptest
@pytest.fixture
def launch(request):
return _init(AppTest.from_file(request.param))
@pytest.mark.parametrize("launch", DIRECTLY_TESTABLE_PAGES, indirect=True)
def test_page_loads(launch):
launch.run(timeout=30)
assert not launch.exception
def test_app_loads():
app = _init(AppTest.from_file("app.py"))
app.run(timeout=30)
assert not app.exception