Files
dxdesigner-part-replacement/tests/ui/test_dsh_native_menu.py
T

50 lines
1.9 KiB
Python

from PySide6.QtCore import Signal, Qt
from PySide6.QtWidgets import QWidget
class HarnessView(QWidget):
action_requested = Signal(object)
def __init__(self, parent):
super().__init__(parent)
self.starts = 0
self.binds = []
def start(self):
self.starts += 1
def bind(self, snapshot, **kwargs):
self.binds.append(snapshot)
self.context = {'task_id': snapshot.task_id, 'revision': 'rev'}
def shutdown(self):
pass
def test_direct_navigation_opens_harness_and_returns_without_losing_task(ui, monkeypatch, qtbot):
window = ui.window
monkeypatch.setattr(type(window), '_create_dsh_view', lambda self: HarnessView(self), raising=False)
task_id = window._task_id
qtbot.mouseClick(window.dsh_navigation, Qt.MouseButton.LeftButton)
assert window.content_stack.currentWidget() is window._dsh_view
assert window._dsh_view.binds[-1].task_id == task_id
assert window._dsh_view.starts == 1
assert window.dsh_navigation.isChecked()
assert window.task_center_navigation.geometry().right() < window.dsh_navigation.geometry().left()
qtbot.mouseClick(window.task_center_navigation, Qt.MouseButton.LeftButton)
assert window.content_stack.currentIndex() == 0
assert window._task_id == task_id
assert window.task_center_navigation.isChecked()
qtbot.mouseClick(window.dsh_navigation, Qt.MouseButton.LeftButton)
assert window._dsh_view.starts == 1
def test_cross_task_harness_action_never_reaches_task_service(ui, monkeypatch):
window = ui.window
monkeypatch.setattr(type(window), '_create_dsh_view', lambda self: HarnessView(self), raising=False)
window.dsh_action.trigger()
called = []
monkeypatch.setattr(window, '_retry_failed', lambda: called.append('retry'))
window._handle_dsh_action({'action': 'retry_failed', 'task_id': 'another', 'revision': 'rev'})
assert not called