FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

refactor main window stacked widget by Robert0Mart · Pull Request #298 · BlocksTechnology/BlocksScreen · GitHub

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (11) .txt  (1) .ui  (2) All 3 file types selected
Only manifest files
Deleted files Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
622 changes: 521 additions & 101 deletions BlocksScreen/lib/panels/mainWindow.py

Large diffs are not rendered by default.

807 changes: 0 additions & 807 deletions BlocksScreen/lib/ui/mainWindow.ui

This file was deleted.

325 changes: 0 additions & 325 deletions BlocksScreen/lib/ui/mainWindow_ui.py

This file was deleted.

981 changes: 0 additions & 981 deletions BlocksScreen/lib/ui/mainWindow_v2.ui

This file was deleted.

360 changes: 0 additions & 360 deletions BlocksScreen/lib/ui/mainWindow_v2_ui.py

This file was deleted.

1 change: 1 addition & 0 deletions scripts/requirements-dev.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pytest-timeout
pytest-qt
pytest-asyncio
PyQt6
numpy==2.1.0
docstr_coverage
bandit
requests>=2.32.5
Expand Down
32 changes: 24 additions & 8 deletions tests/panels/conftest.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,19 @@

import sys
import types
from pathlib import Path
from unittest.mock import MagicMock

_project_root = Path(__file__).resolve().parent.parent.parent

# Other test directories (e.g. tests/lib/conftest.py) leak a bare
# ``MagicMock()`` stub for "lib.utils" into sys.modules with no teardown,
# which breaks the real ``lib.utils.*`` imports below on a full-suite run.
# Clear any stale "lib"/"lib.*" entries before rebuilding our own stubs.
for _stale in list(sys.modules):
if _stale == "lib" or _stale.startswith("lib."):
del sys.modules[_stale]

_STUB_MODULES = (
"events",
"configfile",
Expand All @@ -31,11 +42,11 @@
"lib.panels.utilitiesTab",
"lib.panels.widgets",
"lib.panels.widgets.basePopup",
"lib.panels.widgets.cancelPage",
"lib.panels.widgets.connectionPage",
"lib.panels.widgets.MainWindow.cancelPage",
"lib.panels.widgets.MainWindow.connectionPage",
"lib.panels.widgets.loadWidget",
"lib.panels.widgets.notificationPage",
"lib.panels.widgets.updatePage",
"lib.panels.widgets.MainWindow.notificationPage",
"lib.panels.widgets.MainWindow.updatePage",
"lib.printer",
"lib.ui",
"lib.ui.mainWindow_ui",
Expand All @@ -56,6 +67,11 @@
_mod.__path__ = [] # marks it as a package so submodule imports resolve
sys.modules[_name] = _mod

# "lib.utils" is deliberately NOT in _STUB_MODULES: blocks_tabwidget,
# display_button, and icon_button are plain PyQt6 widgets with no heavy
# deps, so let them load for real from disk instead of stubbing them.
sys.modules["lib"].__path__ = [str(_project_root / "BlocksScreen" / "lib")]

# events.* is referenced as a bare attribute in type annotations
# (e.g. ``event: events.WebSocketMessageReceived``), evaluated eagerly at
# class-definition time — needs to resolve any attribute, not just a fixed set.
Expand All @@ -79,11 +95,11 @@
sys.modules["lib.panels.printTab"].PrintTab = MagicMock
sys.modules["lib.panels.utilitiesTab"].UtilitiesTab = MagicMock
sys.modules["lib.panels.widgets.basePopup"].BasePopup = MagicMock
sys.modules["lib.panels.widgets.cancelPage"].CancelPage = MagicMock
sys.modules["lib.panels.widgets.connectionPage"].ConnectionPage = MagicMock
sys.modules["lib.panels.widgets.MainWindow.cancelPage"].CancelPage = MagicMock
sys.modules["lib.panels.widgets.MainWindow.connectionPage"].ConnectionPage = MagicMock
sys.modules["lib.panels.widgets.loadWidget"].LoadingOverlayWidget = MagicMock
sys.modules["lib.panels.widgets.notificationPage"].NotificationPage = MagicMock
sys.modules["lib.panels.widgets.updatePage"].UpdatePage = MagicMock
sys.modules["lib.panels.widgets.MainWindow.notificationPage"].NotificationPage = MagicMock
sys.modules["lib.panels.widgets.MainWindow.updatePage"].UpdatePage = MagicMock
sys.modules["lib.printer"].Printer = MagicMock
sys.modules["lib.ui.mainWindow_ui"].Ui_MainWindow = MagicMock
sys.modules["lib.updater_worker"].UpdaterWorker = MagicMock
Expand Down
3 changes: 2 additions & 1 deletion tests/panels/test_main_window_unit.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def _make_nav_window(print_state: str) -> SimpleNamespace:
_print_state=print_state,
printPanel=print_panel,
filamentPanel=MagicMock(),
ui=SimpleNamespace(main_content_widget=main_content, printTab=print_tab),
main_content_widget=main_content,
printTab=print_tab,
)
for name in (
"_is_job_active",
Expand Down
2 changes: 1 addition & 1 deletion tests/widgets/test_connection_page.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from unittest.mock import MagicMock
from events import KlippyDisconnected, KlippyReady
from BlocksScreen.lib.panels.widgets.connectionPage import (
from BlocksScreen.lib.panels.widgets.MainWindow.connectionPage import (
ConnectionState,
ConnectionPage,
)
Expand Down
10 changes: 5 additions & 5 deletions tests/widgets/test_update_page_unit.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
def page(qapp):
"""UpdatePage instance with all heavy UI deps mocked."""
patches = [
patch("BlocksScreen.lib.panels.widgets.updatePage.LoadingOverlayWidget"),
patch("BlocksScreen.lib.panels.widgets.updatePage.BlocksCustomButton"),
patch("BlocksScreen.lib.panels.widgets.updatePage.IconButton"),
patch("BlocksScreen.lib.panels.widgets.MainWindow.updatePage.LoadingOverlayWidget"),
patch("BlocksScreen.lib.panels.widgets.MainWindow.updatePage.BlocksCustomButton"),
patch("BlocksScreen.lib.panels.widgets.MainWindow.updatePage.IconButton"),
]
for p in patches:
p.start()

from BlocksScreen.lib.panels.widgets.updatePage import UpdatePage
from BlocksScreen.lib.panels.widgets.MainWindow.updatePage import UpdatePage

def _mock_setup(self):
for attr in (
Expand Down Expand Up @@ -498,7 +498,7 @@ def test_bad_payload_keeps_statuses_and_toasts(self, page):

class TestConfirmPopupCleanup:
def test_second_confirm_deletes_previous_popup(self, page):
with patch("BlocksScreen.lib.panels.widgets.updatePage.BasePopup") as popup_cls:
with patch("BlocksScreen.lib.panels.widgets.MainWindow.updatePage.BasePopup") as popup_cls:
first = MagicMock()
second = MagicMock()
popup_cls.side_effect = [first, second]
Expand Down
Loading

Back | FazBrowse Home | New Git URL