Phase 11
This commit is contained in:
commit
c5bcb95d74
172 files changed
+9487
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import time
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
from src.gui.experiment_controller import ExperimentController
|
||||
from src.gui.gui_models import GuiExperimentRequest
|
||||
CONFIG=str(Path(__file__).parents[1]/"config"/"experiment.yaml")
|
||||
class FakeApp:
|
||||
instances=[]
|
||||
def __init__(self,config,**kwargs):self.stop=False;self.paused=False;self.kwargs=kwargs;FakeApp.instances.append(self)
|
||||
def run(self):
|
||||
while not self.stop:time.sleep(.005)
|
||||
def request_stop(self):self.stop=True
|
||||
def request_pause(self):self.paused=True
|
||||
def request_resume(self):self.paused=False
|
||||
def test_controller_start_stop_pause_without_camera()->None:
|
||||
c=ExperimentController(FakeApp);c.start_experiment(GuiExperimentRequest(config_path=CONFIG));time.sleep(.02)
|
||||
assert c.is_running();c.pause_experiment();assert FakeApp.instances[-1].paused;c.resume_experiment();assert not FakeApp.instances[-1].paused;c.stop_experiment();time.sleep(.03);assert not c.is_running()
|
||||
def test_controller_prevents_double_start()->None:
|
||||
c=ExperimentController(FakeApp);c.start_experiment(GuiExperimentRequest(config_path=CONFIG));
|
||||
with pytest.raises(RuntimeError):c.start_experiment(GuiExperimentRequest(config_path=CONFIG))
|
||||
c.stop_experiment()
|
||||
Reference in new issue
Block a user