Initial commit: MISF VOB download and upload automation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
c2dec96b1f
43 files changed
+10944
No files matched your search
@@ -0,0 +1,99 @@
|
||||
"""Unit tests for task-details panel status detection (scoped to panel, not board)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from selenium.webdriver.common.by import By
|
||||
|
||||
from onedrive_planner import (
|
||||
_panel_progress_status_label,
|
||||
_task_details_shows_in_progress,
|
||||
_task_details_shows_not_started,
|
||||
)
|
||||
|
||||
|
||||
def _panel(*, status_aria: str):
|
||||
panel = MagicMock()
|
||||
panel.is_displayed.return_value = True
|
||||
status_btn = MagicMock()
|
||||
status_btn.is_displayed.return_value = True
|
||||
status_btn.get_attribute.side_effect = lambda name: (
|
||||
status_aria if name == "aria-label" else ""
|
||||
)
|
||||
title_box = MagicMock()
|
||||
title_box.is_displayed.return_value = True
|
||||
title_box.text = "6.5.26"
|
||||
|
||||
def find_elements(by, xpath):
|
||||
xp = xpath or ""
|
||||
if "Not started" in xp or "In progress" in xp or "Completed" in xp:
|
||||
return [status_btn]
|
||||
if "textbox" in xp:
|
||||
return [title_box]
|
||||
if "Status" in xp:
|
||||
return []
|
||||
return []
|
||||
|
||||
panel.find_elements.side_effect = find_elements
|
||||
return panel
|
||||
|
||||
|
||||
def _driver_with_panel(panel, *, board_in_progress: bool = False):
|
||||
drv = MagicMock()
|
||||
board_btn = MagicMock()
|
||||
board_btn.is_displayed.return_value = board_in_progress
|
||||
board_btn.get_attribute.side_effect = lambda name: (
|
||||
"In progress" if name == "aria-label" else ""
|
||||
)
|
||||
|
||||
def find_elements(by, xpath):
|
||||
xp = xpath or ""
|
||||
if "@role='dialog'" in xp or "TaskDetails" in xp or "Close task" in xp:
|
||||
return [panel]
|
||||
if "In progress" in xp and xp.startswith("//button"):
|
||||
return [board_btn] if board_in_progress else []
|
||||
if "Close" in xp:
|
||||
return []
|
||||
return []
|
||||
|
||||
drv.find_elements.side_effect = find_elements
|
||||
return drv
|
||||
|
||||
|
||||
class TestTaskPanelStatus:
|
||||
def test_panel_not_started(self):
|
||||
panel = _panel(status_aria="Not started")
|
||||
assert _panel_progress_status_label(panel) == "not started"
|
||||
|
||||
def test_panel_in_progress(self):
|
||||
panel = _panel(status_aria="In progress")
|
||||
assert _panel_progress_status_label(panel) == "in progress"
|
||||
|
||||
def test_details_not_started_ignores_board_buttons(self):
|
||||
panel = _panel(status_aria="Not started")
|
||||
drv = _driver_with_panel(panel, board_in_progress=True)
|
||||
assert _task_details_shows_not_started(drv)
|
||||
assert not _task_details_shows_in_progress(drv)
|
||||
|
||||
def test_details_in_progress_from_panel_only(self):
|
||||
panel = _panel(status_aria="In progress")
|
||||
drv = _driver_with_panel(panel, board_in_progress=False)
|
||||
assert _task_details_shows_in_progress(drv)
|
||||
assert not _task_details_shows_not_started(drv)
|
||||
|
||||
def test_panel_in_progress_from_combobox_value(self):
|
||||
panel = MagicMock()
|
||||
panel.is_displayed.return_value = True
|
||||
combo = MagicMock()
|
||||
combo.is_displayed.return_value = True
|
||||
combo.get_attribute.side_effect = lambda name: "inProgress" if name == "value" else ""
|
||||
combo.text = ""
|
||||
|
||||
def find_elements(by, xpath):
|
||||
xp = xpath or ""
|
||||
if "combobox" in xp or "ComboBox" in xp:
|
||||
return [combo]
|
||||
return []
|
||||
|
||||
panel.find_elements.side_effect = find_elements
|
||||
assert _panel_progress_status_label(panel) == "in progress"
|
||||
Reference in new issue
Block a user