Add tests for local-dev CLI and config utilities
This PR adds comprehensive tests for:
- The
local_devCLI command which was added in PR #568 - The config.py utilities, specifically the
ContextandConfigclasses
Tests Added
For local_dev CLI:
- Created
test_local_dev_utils.pyhelper module with functions that test the core functionality without CLI dependencies - Added tests for various scenarios:
- When all resources exist (compute cluster, nodepool, runner)
- When compute cluster exists but runner doesn't exist
- When compute cluster exists but nodepool doesn't exist
- When compute cluster doesn't exist
For config.py:
- Created
tests/test_config.pywith comprehensive tests for:-
Contextclass:- Initialization with env parameter and kwargs
- Get/set/delete attributes
- Environment variable handling
- Serialization to dict
- Setting environment variables
-
Configclass:- Loading from YAML
- Serialization to dict and YAML
- Current context property
- Post-initialization processing
-
Implementation Approach
For the local_dev CLI tests, I avoided directly using the Click command infrastructure which would require significantly more mocking and complexity. Instead, I created utility functions that test the core logic directly, ensuring we verify that the function's behavior is correct for various scenarios.
The config.py tests are traditional unit tests that verify the functionality of the various methods and properties of the Context and Config classes.
Fixes #590.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
api.test.com
- Triggering command:
python -m pytest tests/cli/test_compute_orchestration.py::TestLocalDevCLI -v(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.