You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

17 lines
971 B

import time
from pathlib import Path
import pytest
from src.gui.analysis_controller import AnalysisController
from src.gui.gui_models import GuiAnalysisRequest
def test_analysis_runner_and_callback(tmp_path:Path)->None:
expected=[tmp_path/"condition_summary.csv"];finished=[]
c=AnalysisController(lambda settings,i,o:expected);c.set_finished_callback(finished.extend);c.run_analysis(GuiAnalysisRequest(output_directory=str(tmp_path)));time.sleep(.05)
assert finished==expected
def test_analysis_double_run_guard()->None:
def slow(s,i,o):time.sleep(.1);return []
c=AnalysisController(slow);c.run_analysis(GuiAnalysisRequest())
with pytest.raises(RuntimeError):c.run_analysis(GuiAnalysisRequest())
def test_analysis_error_callback()->None:
errors=[]
def fail(s,i,o):raise RuntimeError("broken")
c=AnalysisController(fail);c.set_error_callback(errors.append);c.run_analysis(GuiAnalysisRequest());time.sleep(.05);assert errors==["broken"]