76 lines
2.0 KiB
Python
76 lines
2.0 KiB
Python
import pytest
|
|
from PySide6.QtWidgets import QWidget
|
|
|
|
from aare.gui.tutorials.tutorial_manager import TutorialManager
|
|
from aare.gui.tutorials.tutorial_models import (
|
|
StepKind,
|
|
TargetKind,
|
|
TutorialMode,
|
|
TutorialScenario,
|
|
TutorialStepDefinition,
|
|
TutorialTarget,
|
|
TutorialTextRef,
|
|
)
|
|
from aare.gui.tutorials.tutorial_runtime import (
|
|
DictionaryTextResolver,
|
|
DictTargetResolver,
|
|
NoOpActionExecutor,
|
|
TutorialEventBus,
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_window(qapp):
|
|
return QWidget()
|
|
|
|
|
|
@pytest.fixture
|
|
def tutorial_scenario():
|
|
step1 = TutorialStepDefinition(
|
|
id="step1",
|
|
kind=StepKind.INFO,
|
|
title=TutorialTextRef(key="step1_title"),
|
|
body=TutorialTextRef(key="step1_body"),
|
|
target=TutorialTarget(kind=TargetKind.NONE, target_id=""),
|
|
)
|
|
scenario = TutorialScenario(
|
|
id="test_scenario",
|
|
title=TutorialTextRef(key="scenario_title"),
|
|
description=TutorialTextRef(key="scenario_desc"),
|
|
mode=TutorialMode.LINEAR,
|
|
steps=[step1],
|
|
)
|
|
return scenario
|
|
|
|
|
|
def test_tutorial_manager_start_stop(qtbot, mock_window, tutorial_scenario):
|
|
text_resolver = DictionaryTextResolver(
|
|
{
|
|
"en": {
|
|
"step1_title": "Step 1",
|
|
"step1_body": "This is step 1",
|
|
"scenario_title": "Test",
|
|
"scenario_desc": "Test Desc",
|
|
}
|
|
}
|
|
)
|
|
target_resolver = DictTargetResolver({})
|
|
action_executor = NoOpActionExecutor()
|
|
event_bus = TutorialEventBus()
|
|
|
|
manager = TutorialManager(
|
|
parent_window=mock_window,
|
|
target_resolver=target_resolver,
|
|
text_resolver=text_resolver,
|
|
action_executor=action_executor,
|
|
event_bus=event_bus,
|
|
)
|
|
manager.add_scenario(tutorial_scenario)
|
|
|
|
manager.start("test_scenario")
|
|
assert manager.get_current_step() is not None
|
|
assert manager.get_current_step().id == "step1"
|
|
|
|
manager.stop()
|
|
assert manager.get_current_step() is None
|