Some checks failed
CI / lint (push) Has been cancelled
CI / test (macos-latest, 3.10) (push) Has been cancelled
CI / test (macos-latest, 3.11) (push) Has been cancelled
CI / test (macos-latest, 3.12) (push) Has been cancelled
CI / test (ubuntu-latest, 3.10) (push) Has been cancelled
CI / test (ubuntu-latest, 3.11) (push) Has been cancelled
CI / test (ubuntu-latest, 3.12) (push) Has been cancelled
CI / test (windows-latest, 3.10) (push) Has been cancelled
CI / test (windows-latest, 3.11) (push) Has been cancelled
CI / test (windows-latest, 3.12) (push) Has been cancelled
- core/units: two dominant systems (Metric m/kN, Imperial ft/kip) with display conversion helpers, legacy 4-system migration in ProjectMeta - dialogs/docks: unit-aware material, section, case, load, grid and results labels; diagram renderer unit labels; render controls update - docs: add consistent_units.md; regen examples/*.osmodel artifacts - tests: update persistence/phase8/project/unit-labels for new systems
57 lines
1.8 KiB
Python
57 lines
1.8 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 # noqa: E402
|
|
|
|
|
|
@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.IMPERIAL
|
|
mw._sync_units_combo()
|
|
assert mw._units_combo.currentData() == UnitSystem.IMPERIAL
|
|
|
|
|
|
@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 Metric — switch to Imperial via the combo.
|
|
target_idx = mw._units_combo.findData(UnitSystem.IMPERIAL)
|
|
mw._units_combo.setCurrentIndex(target_idx)
|
|
assert mw._vm.project.meta.units == UnitSystem.IMPERIAL
|
|
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
|