Refactor: modernize helper_methods + port Mainsail layer formulas to jobStatusPage#208
Draft
gmmcosta15 wants to merge 2 commits intodevfrom
Draft
Refactor: modernize helper_methods + port Mainsail layer formulas to jobStatusPage#208gmmcosta15 wants to merge 2 commits intodevfrom
gmmcosta15 wants to merge 2 commits intodevfrom
Conversation
- 40 unit tests across 8 test classes covering all public slots: on_print_start, _handle_print_state, on_print_stats_update, on_gcode_move_update, virtual_sdcard_update, pause_resume_print, handleCancel, on_fileinfo - tests/widgets/conftest.py: fix cross-suite isolation (clears empty lib.* stubs registered by network conftest, ensures BlocksScreen/on sys.path) - jobStatusPage: frozenset class constants, compound guard, if/elif chains, _post_event helper, walrus list comprehension, removed no-op QPixmap.scaled, removed spurious show() on collapse
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refactors
helper_methods.pyandjobStatusPage.py, and adds a full unit test suite forJobStatusWidget.jobStatusPage.py
_VALID_STATES/_INVALID_STATES->frozensetclass constants (avoid per-call realloc)on_gcode_move_update- 7 individual guards collapsed into one compoundorguardon_print_stats_update-if/if->if/elifchains (mutually exclusive branches)_post_eventhelper - DRY up duplicatedQApplication.postEventpattern_load_thumbnails- manual loop -> walrus list comprehensionQPixmap.scaled()to identical dimensionsself.show()on thumbnail collapsehelper_methods.py
calculate_current_layer/calculate_max_layerstests/widgets/test_job_status_page_unit.py - 40 unit tests
TestOnPrintStart(4),TestHandlePrintState(7),TestOnPrintStatsUpdate(6)TestOnGcodeMoveUpdate(8),TestVirtualSdcardUpdate(3)TestPauseResumePrint(6),TestHandleCancel(4),TestOnFileInfo(5)tests/widgets/conftest.py
BlocksScreen/onsys.pathforlib.*importslib.*namespace stubs registered by the network conftest so widget tests can coexist in the fullmake test-fastrunMotivation
The refactors reduce duplicated code and allocation overhead in the hottest print-progress paths. The test suite documents the expected slot behaviour and will catch regressions in the state machine, signal wiring, and layer-calculation logic.
Tests
Widget tests alone:
40 passed