tests: add unit tests for observal_cli/cmd_scan.py#1369
Open
AnupamKumar-1 wants to merge 1 commit into
Open
Conversation
Haz3-jolt
approved these changes
Jun 6, 2026
Haz3-jolt
left a comment
Contributor
There was a problem hiding this comment.
Well-structured test suite for cmd_scan. Good use of mocking, proper SPDX header, and covers the key paths (no IDEs, single MCP, IDE filter, deduplication). LGTM.
Contributor
Author
|
Thanks for the review and approval. Could someone approve the pending workflows when convenient? Let me know if anything is needed from my side. Thanks! |
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.
Closes #1363
Purpose / Description
cmd_scan.pyis the entry point forobserval scanbut had no dedicated unit tests. This PR addstests/test_cmd_scan.pycovering the core scan logic — IDE discovery, MCP table output,--idefiltering, and MCP deduplication.Fixes
observal_cli/cmd_scan.py#1363Approach
Created
tests/test_cmd_scan.pywith 6 test cases organised into 4 classes:TestScanNoIdes— verifies that when no IDE home directories exist, the command exits with code 1 and prints a message.TestScanOneMcp— verifies that a single discovered MCP server appears in the output table and the component count is correct.TestScanIdeFilter— verifies that--idewith an unknown IDE name exits with code 1 and prints an error, and that a valid--ideflag only invokes that adapter.TestScanDeduplication— verifies that an MCP with the same name found in both home and project directories is counted only once.All external dependencies (
get_all_adapters,spinner,Path.is_dir,_is_already_shimmed) are mocked so no Docker or real filesystem is needed.How Has This Been Tested?
Run the tests locally with:
Output:
Ruff lint also passes:
uv run ruff check tests/test_cmd_scan.py # All checks passed!No Docker required — all external services are mocked.
Checklist