Skip to content

Fix _make_mock_winreg and add registry-path unit tests - #34

Open
kwuuuuu wants to merge 2 commits into
mcp-servers-for-revit:masterfrom
kwuuuuu:add-registry-tests
Open

Fix _make_mock_winreg and add registry-path unit tests#34
kwuuuuu wants to merge 2 commits into
mcp-servers-for-revit:masterfrom
kwuuuuu:add-registry-tests

Conversation

@kwuuuuu

@kwuuuuu kwuuuuu commented Jun 21, 2026

Copy link
Copy Markdown

What changed

_make_mock_winreg in tests/unit/test_find_installations.py existed but was never wired to any test cases. The helper had a bug: winreg.OpenKey is called twice per subkey once with an integer hive constant to open the base key and again with the returned handle to open the named subkey. The original stub only handled the hive-constant form and always raised OSError for the subkey open making the entire registry branch of _find_revit_installations unreachable from tests.

What this PR does

  • Fixes _make_mock_winreg to distinguish both OpenKey call forms so subkeys can actually be opened and queried.
  • Adds TestFindInstallationsRegistry with 5 new tests: single install found, multiple versions sorted newest-first, deduplication with filesystem, missing exe skipped, and hive-absent fallthrough to filesystem.

Test results

69 passed (was 64), 0 failures.

Reviewer notes

No production code changed. This is a test-coverage fix for the primary discovery strategy (Windows Registry) which had zero unit test coverage.

kwuuuuu and others added 2 commits June 21, 2026 12:04
The _make_mock_winreg helper existed but was never wired to any tests
because its open_key stub only handled the initial hive-constant call and
always raised OSError for the subkey open, making the registry branch
unreachable. Fixed the helper to distinguish both call forms and added
TestFindInstallationsRegistry covering: single install found, multiple
versions sorted, deduplication with filesystem, missing exe skipped, and
hive-absent fallthrough to filesystem.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests for revit_available=False (error path), extra fields in active
status responses, and unknown keys in error responses were absent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant