Repository navigation
Add coverage tests for mainApp, Landing_page and Bin_Phase_env (71% -> 79%) - #146
Merged
Koyandechirag merged 1 commit intoNov 15, 2026
Conversation
Raises overall coverage from 71% to 79%: - mainApp.py 53% -> 99%: drag/drop filters, component placement grid and fallback, new/new_file/new_project, undo/redo, save/open round trip, legacy .sim conversion, simulate/terminate, closeEvent. - Landing_page.py 66% -> 97%: preload, start/open project flows and errors, window stashing, delayed canvas fit, IntroPage handlers, fit_canvas, close, About and run(). - Bin_Phase_env.py 73% -> 100%: input validation, OMC lookup on Windows/Linux, OMC failures, empty/bad results, temp file cleanup and plot mouse handlers. Tests never open real modal dialogs or start simulation threads, keep undo/redo files in a temporary folder, and destroy each MainApp window in tearDown so the suite stays fast. No application code changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Adds unit tests for the remaining low-coverage modules
mainApp.py,Landing_page.pyandutils/Bin_Phase_env.py. No application code is changed.mainApp.pyLanding_page.pyutils/Bin_Phase_env.pyFull suite: 470 passed on 3 runs (Windows, Python 3.13,
QT_QPA_PLATFORM=offscreen), measured with the same--cov=src/main/pythoncommand as the CI workflow.What's covered
tests/test_main_app.py(+74 tests)DragButtonFilter/DropFilter: a press followed by a long or short move, the drag carrying the component type, drop creating the component at the mapped scene position, non-text drags ignored.component(): compounds required; MaterialStream gets the selected compounds; unknown types ignored; drop position used; click-to-add grid (5 per row, 180px apart, wrapping 150px down); the fallback positioning path whenadd_unit_operationreturnsNone.new()/new_file()/new_project(): counters, dock widgets, compounds and container reset, one initial Undo snapshot, deleted dock widgets skipped, errors reported; Save / Don't Save / Cancel, including a cancelled Save As.undo_redo_helper._legacy_sim_to_snapshot(items, positions, compounds, rebuilt connections)..mofound or missing, start failure unlocks the UI,terminate()(omc process, async exception, revert when more than one thread was affected),closeEvent.select_compounds.tests/test_landing_page.py(+28 tests)Preload (success and failure); start simulation via its timer; compound selector shown and landing page restored when the main window closes;
_cleanup_main_windowstashing old windows and clearing the Graphics lists (including error paths); opening a project, with the delayed canvas fit, empty projects, fit errors, open failures and the preloaded window stashed; IntroPage handlers;fit_canvas; restoring and draining override cursors;closeEvent; the About window;run().tests/test_bin_phase_env.py(+32 tests)Thermo package fallback when
thermopackage.txtis missing; mode switching detaching the old inputs; every validation message; OMC lookup viaOPENMODELICAHOME(omc and omc.exe), the Windows glob and default path, and the Linux/opt/local, plus not found; the generatedGraph.mo/PlotGraph.moscontent; OMC not found or failing to launch (cwd restored); the error summary; empty or unusable result CSVs; unparseable values skipped; numbered plot tabs and axis labels; the plot's mouse-move and hover handlers; temporary files removed.Test hygiene
QMessageBox.about/critical/warning,exec_(), file dialogs) are always patched, so nothing can block a headless CI run.Simulator/undo_redo.MainAppwindow is destroyed intearDown. Leaving the windows alive madetest_main_app.pytake over 3 minutes, because each new window restyles every existing one; with cleanup it takes about 37s.Note
The remaining uncovered lines are
Landing_page.py'sif __name__ == "__main__"block and import fallback, and one line inmainApp.py. I also noticed thatDragButtonFilterignores a drag that starts at exactly (0, 0) on the button, becauseQPoint(0, 0)is falsy. It's harmless, so I left it unchanged.🤖 Generated with Claude Code