Some checks failed
CI / lint (pull_request) Has been cancelled
CI / type (pull_request) Has been cancelled
CI / test-headless (macos-latest, 3.10) (pull_request) Has been cancelled
CI / test-headless (macos-latest, 3.11) (pull_request) Has been cancelled
CI / test-headless (macos-latest, 3.12) (pull_request) Has been cancelled
CI / test-headless (ubuntu-latest, 3.10) (pull_request) Has been cancelled
CI / test-headless (ubuntu-latest, 3.11) (pull_request) Has been cancelled
CI / test-headless (ubuntu-latest, 3.12) (pull_request) Has been cancelled
CI / test-headless (windows-latest, 3.10) (pull_request) Has been cancelled
CI / test-headless (windows-latest, 3.11) (pull_request) Has been cancelled
CI / test-headless (windows-latest, 3.12) (pull_request) Has been cancelled
CI / test-gui (pull_request) Has been cancelled
CI / test-integration (macos-latest) (pull_request) Has been cancelled
CI / test-integration (ubuntu-latest) (pull_request) Has been cancelled
CI / test-integration (windows-latest) (pull_request) Has been cancelled
Auto-fixes (UP037, UP038, F401, I001, SIM105, RUF100) plus hand-fixes: drop the now-unused `Union` imports, annotate mutable class attributes with ClassVar, raise ValidationError instead of blind Exception in the zero-length test, delete two dead locals, and bind the per-iteration grid-builder closures to their loop variables (B023).
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
"""Status-bar unit picker syncs with Project.meta.units."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
pytest.importorskip("PySide6")
|
|
|
|
from otko.core import UnitSystem
|
|
|
|
|
|
@pytest.mark.gui
|
|
def test_status_bar_combo_lists_all_unit_systems(qtbot) -> None: # type: ignore[no-untyped-def]
|
|
from otko.views.main_window import MainWindow
|
|
|
|
mw = MainWindow()
|
|
qtbot.addWidget(mw)
|
|
assert mw._units_combo.count() == len(list(UnitSystem))
|
|
|
|
|
|
@pytest.mark.gui
|
|
def test_status_bar_combo_reflects_project_units(qtbot) -> None: # type: ignore[no-untyped-def]
|
|
from otko.views.main_window import MainWindow
|
|
|
|
mw = MainWindow()
|
|
qtbot.addWidget(mw)
|
|
mw._vm.new_project()
|
|
mw._vm.project.meta.units = UnitSystem.US_IN_KIP
|
|
mw._sync_units_combo()
|
|
assert mw._units_combo.currentData() == UnitSystem.US_IN_KIP
|
|
|
|
|
|
@pytest.mark.gui
|
|
def test_status_bar_combo_write_updates_project(qtbot) -> None: # type: ignore[no-untyped-def]
|
|
"""Changing the combo writes through to project.meta.units."""
|
|
from otko.views.main_window import MainWindow
|
|
|
|
mw = MainWindow()
|
|
qtbot.addWidget(mw)
|
|
mw._vm.new_project()
|
|
# Default is SI_M_N — switch to US_IN_KIP via the combo.
|
|
target_idx = mw._units_combo.findData(UnitSystem.US_IN_KIP)
|
|
mw._units_combo.setCurrentIndex(target_idx)
|
|
assert mw._vm.project.meta.units == UnitSystem.US_IN_KIP
|
|
assert mw._vm.is_dirty
|
|
|
|
|
|
@pytest.mark.gui
|
|
def test_status_bar_combo_no_project_noop(qtbot) -> None: # type: ignore[no-untyped-def]
|
|
"""Before a project is loaded, changing the combo is a no-op."""
|
|
from otko.views.main_window import MainWindow
|
|
|
|
mw = MainWindow()
|
|
qtbot.addWidget(mw)
|
|
# No crash even with no project.
|
|
mw._units_combo.setCurrentIndex(2)
|
|
assert mw._vm.project is None
|