Skip to content

Add targeted coverage tests for tools and core helpers#1208

Merged
AdvancedImagingUTSW merged 3 commits intodevelopfrom
add-tests-for-gaps
Mar 21, 2026
Merged

Add targeted coverage tests for tools and core helpers#1208
AdvancedImagingUTSW merged 3 commits intodevelopfrom
add-tests-for-gaps

Conversation

@AdvancedImagingUTSW
Copy link
Collaborator

Summary

  • Add targeted tests for tool helpers, logging filters, thread warning handling, data source factory dispatch, CLI startup paths, and commit/version helpers
  • Make image and multiposition tool tests run headlessly by replacing Tcl-dependent paths with mocks/test doubles
  • Fix waveform_constants_file argument handling in src/navigate/tools/main_functions.py
  • Refresh the tools coverage report in tools-coverage.xml

Testing

  • uv run pytest test/tools --override-ini "addopts=--strict-markers -m 'not hardware'" --cov=src/navigate/tools --cov-report=term-missing:skip-covered --cov-report=xml:tools-coverage.xml
  • uv run ruff check test/tools/test_common_functions_additional.py test/tools/test_decorators_additional.py test/tools/test_file_functions_more.py test/tools/test_image.py test/tools/test_linear_algebra_additional.py test/tools/test_multipos_table_tools.py test/tools/test_sdf_additional.py test/tools/test_slicing_additional.py test/tools/test_tk_thread_guard_additional.py
  • uv run ruff format --check test/tools/test_common_functions_additional.py test/tools/test_decorators_additional.py test/tools/test_file_functions_more.py test/tools/test_image.py test/tools/test_linear_algebra_additional.py test/tools/test_multipos_table_tools.py test/tools/test_sdf_additional.py test/tools/test_slicing_additional.py test/tools/test_tk_thread_guard_additional.py

Copilot AI review requested due to automatic review settings March 21, 2026 21:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the reliability and completeness of the navigate test suite by adding focused unit tests around tools helpers and a few core runtime helpers, while also fixing CLI argument handling for waveform_constants_file in src/navigate/tools/main_functions.py.

Changes:

  • Add targeted tests for tool helpers (slicing, SDF volume generation, linear algebra, decorators, file functions), plus Tk thread guard and headless GUI-adjacent utilities.
  • Add tests for core runtime helpers (main entrypoint branch behavior, logging filters/functions, thread warning handling, data source factory dispatch, commit/version helpers).
  • Fix CLI parsing/evaluation to correctly validate and use --waveform-constants-file, and refresh tools-coverage.xml.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools-coverage.xml Adds/updates Cobertura XML coverage output for src/navigate/tools.
src/navigate/tools/main_functions.py Fixes waveform_constants_file handling and adjusts some assertion formatting/help text.
test/tools/test_tk_thread_guard_additional.py Adds coverage for skipping non-callable/missing Tk methods during guard installation.
test/tools/test_slicing_additional.py Adds coverage for key_len, ensure_iter, and ensure_slice edge cases.
test/tools/test_sdf_additional.py Adds a test for volume_from_sdf pixel sizing and z-subsampling behavior.
test/tools/test_multipos_table_tools.py Makes multiposition table tests headless via a lightweight table double; minor cleanups.
test/tools/test_main_functions_additional.py Adds parser/evaluation tests for overrides/defaults and waveform constants validation.
test/tools/test_linear_algebra_additional.py Adds tests for combined-axis rotation and shared shear branches.
test/tools/test_image.py Makes arrow-image tests headless by mocking ttk.Style; minor type-check improvement.
test/tools/test_file_functions_more.py Adds a test for get_ram_info using a psutil mock.
test/tools/test_decorators_additional.py Adds tests for performance_monitor payload behavior and log_initialization logging.
test/tools/test_common_functions_additional.py Adds tests for module/param loaders, byte decoding, and VariableWithLock.
test/test_main_additional.py Adds tests for navigate.main controller vs configurator branch behavior and listener shutdown.
test/test_commit_additional.py Adds tests for git hash retrieval behavior and version file reading.
test/model/test_threads.py Adds tests for ThreadWithWarning queue behavior and default logger usage.
test/model/data_sources/test_factory.py Adds tests for file-type to data-source dispatch and unknown-type error logging.
test/log_files/test_log_functions_additional.py Adds tests for log filename matching, pruning, performance log loading, and log_setup.
test/log_files/test_filters.py Adds tests for routing performance vs non-performance log records.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.10.7 -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
<source>/Users/Dean/Documents/GitHub/navigate/src/navigate/tools</source>
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Cobertura entry contains an absolute, machine-specific path (including a username/home directory). This makes the report non-portable and leaks local filesystem details into the repo. Configure coverage.py to emit relative paths (e.g., set relative_files=true and/or adjust the source setting) before committing the XML.

Suggested change
<source>/Users/Dean/Documents/GitHub/navigate/src/navigate/tools</source>
<source>src/navigate/tools</source>

Copilot uses AI. Check for mistakes.
Comment on lines 101 to +113
if args.experiment_file:
assert (
args.experiment_file.exists()
), "experiment_file file Path {} not valid".format(args.experiment_file)
assert args.experiment_file.exists(), (
"experiment_file file Path {} not valid".format(args.experiment_file)
)
experiment_path = args.experiment_file

if args.waveform_constants_file:
assert (
args.waveform_constants_path.exists()
), "waveform_constants_path Path {} not valid".format(
args.waveform_constants_path
assert args.waveform_constants_file.exists(), (
"waveform_constants_file Path {} not valid".format(
args.waveform_constants_file
)
)
waveform_constants_path = args.waveform_constants_path
waveform_constants_path = args.waveform_constants_file
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Input validation here relies on assert statements. Assertions are stripped when Python runs with optimizations (-O), which would disable these checks in some deployments. Prefer raising a real exception (e.g., FileNotFoundError/ValueError) or calling parser.error(...) during argument parsing so invalid paths are always rejected.

Copilot uses AI. Check for mistakes.
args.experiment_file.exists()
), "experiment_file file Path {} not valid".format(args.experiment_file)
assert args.experiment_file.exists(), (
"experiment_file file Path {} not valid".format(args.experiment_file)
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assertion message has a duplicated word: "experiment_file file Path ...". This reads like a typo and makes CLI failures less clear; consider changing it to something like "experiment_file Path ... not valid" for consistency with the other messages.

Suggested change
"experiment_file file Path {} not valid".format(args.experiment_file)
"experiment_file Path {} not valid".format(args.experiment_file)

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Mar 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.84%. Comparing base (3999f2c) to head (55cce7d).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1208      +/-   ##
===========================================
+ Coverage    63.65%   63.84%   +0.18%     
===========================================
  Files          189      189              
  Lines        26029    26029              
===========================================
+ Hits         16569    16618      +49     
+ Misses        9460     9411      -49     
Flag Coverage Δ
unittests 63.84% <100.00%> (+0.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AdvancedImagingUTSW AdvancedImagingUTSW merged commit 45bddc1 into develop Mar 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants