Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 66 additions & 40 deletions test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,67 @@
from pathlib import Path
import shutil


@pytest.fixture
def launch(request):
test = AppTest.from_file(request.param)

## Initialize session state ##
with open("settings.json", "r") as f:
test.session_state.settings = json.load(f)
test.session_state.settings['test'] = True
test.secrets['workspace'] = 'test'
test.session_state.settings["test"] = True
test.secrets["workspace"] = "test"
return test



# Test launching of all pages
@pytest.mark.parametrize('launch', (
#"content/quickstart.py", # NOTE: this page does not work due to streamlit.errors.StreamlitPageNotFoundError error
"content/documentation.py",
"content/topp_workflow_file_upload.py",
"content/topp_workflow_parameter.py",
"content/topp_workflow_execution.py",
"content/topp_workflow_results.py",
"content/file_upload.py",
"content/raw_data_viewer.py",
"content/run_example_workflow.py",
"content/download_section.py",
"content/simple_workflow.py",
"content/run_subprocess.py"), indirect=True)
@pytest.mark.parametrize(
"launch",
(
# "content/quickstart.py", # NOTE: this page does not work due to streamlit.errors.StreamlitPageNotFoundError error
"content/documentation.py",
"content/topp_workflow_file_upload.py",
"content/topp_workflow_parameter.py",
"content/topp_workflow_execution.py",
"content/topp_workflow_results.py",
"content/file_upload.py",
"content/raw_data_viewer.py",
"content/run_example_workflow.py",
"content/download_section.py",
"content/simple_workflow.py",
"content/run_subprocess.py",
),
indirect=True,
)
def test_launch(launch):
launch.run()
"""Test if all pages can be launched without errors."""
launch.run(timeout=30) # Increased timeout from 10 to 30 seconds
assert not launch.exception



########### PAGE SPECIFIC TESTS ############
@pytest.mark.parametrize('launch,selection', [("content/documentation.py", 'User Guide'),
("content/documentation.py", 'Installation'),
("content/documentation.py", 'Developers Guide: How to build app based on this template'),
("content/documentation.py", 'Developers Guide: TOPP Workflow Framework'),
("content/documentation.py", 'Developer Guide: Windows Executables'),
("content/documentation.py", 'Developers Guide: Deployment')], indirect=['launch'])
@pytest.mark.parametrize(
"launch,selection",
[
("content/documentation.py", "User Guide"),
("content/documentation.py", "Installation"),
(
"content/documentation.py",
"Developers Guide: How to build app based on this template",
),
("content/documentation.py", "Developers Guide: TOPP Workflow Framework"),
("content/documentation.py", "Developer Guide: Windows Executables"),
("content/documentation.py", "Developers Guide: Deployment"),
],
indirect=["launch"],
)
def test_documentation(launch, selection):
launch.run()
launch.selectbox[0].select(selection).run()
assert not launch.exception


@pytest.mark.parametrize('launch', ["content/file_upload.py"], indirect=True)
@pytest.mark.parametrize("launch", ["content/file_upload.py"], indirect=True)
def test_file_upload_load_example(launch):
launch.run()
for i in launch.tabs:
Expand All @@ -61,12 +75,18 @@ def test_file_upload_load_example(launch):


# NOTE: All tabs are automatically checked
@pytest.mark.parametrize('launch,example', [("content/raw_data_viewer.py", 'Blank.mzML'),
("content/raw_data_viewer.py", 'Treatment.mzML'),
("content/raw_data_viewer.py", 'Pool.mzML'),
("content/raw_data_viewer.py", 'Control.mzML')], indirect=['launch'])
@pytest.mark.parametrize(
"launch,example",
[
("content/raw_data_viewer.py", "Blank.mzML"),
("content/raw_data_viewer.py", "Treatment.mzML"),
("content/raw_data_viewer.py", "Pool.mzML"),
("content/raw_data_viewer.py", "Control.mzML"),
],
indirect=["launch"],
)
def test_view_raw_ms_data(launch, example):
launch.run(timeout=10)
launch.run(timeout=30) # Increased timeout from 10 to 30 seconds

## Load Example file, based on implementation of fileupload.load_example_mzML_files() ###
mzML_dir = Path(launch.session_state.workspace, "mzML-files")
Expand All @@ -76,16 +96,22 @@ def test_view_raw_ms_data(launch, example):
shutil.copy(f, mzML_dir)
launch.run()

## TODO: Figure out a way to select a spectrum to be displayed
## TODO: Figure out a way to select a spectrum to be displayed
launch.selectbox[0].select(example).run()
assert not launch.exception


@pytest.mark.parametrize('launch,example', [("content/run_example_workflow.py", ['Blank']),
("content/run_example_workflow.py", ['Treatment']),
("content/run_example_workflow.py", ['Pool']),
("content/run_example_workflow.py", ['Control']),
("content/run_example_workflow.py", ['Control', 'Blank'])], indirect=['launch'])
@pytest.mark.parametrize(
"launch,example",
[
("content/run_example_workflow.py", ["Blank"]),
("content/run_example_workflow.py", ["Treatment"]),
("content/run_example_workflow.py", ["Pool"]),
("content/run_example_workflow.py", ["Control"]),
("content/run_example_workflow.py", ["Control", "Blank"]),
],
indirect=["launch"],
)
def test_run_workflow(launch, example):
launch.run()
## Load Example file, based on implementation of fileupload.load_example_mzML_files() ###
Expand All @@ -96,13 +122,13 @@ def test_run_workflow(launch, example):
shutil.copy(f, mzML_dir)
launch.run()

## Select experiments to process
## Select experiments to process
for e in example:
launch.multiselect[0].select(e)

launch.run()
assert not launch.exception

# Press the "Run Workflow" button
launch.button[1].click().run(timeout=60)
assert not launch.exception
assert not launch.exception