test(config): comprehensive test suite for _apply_env_overrides and from_file (+66 tests) - #172
Open
manus-use wants to merge 6 commits into
Open
test(config): comprehensive test suite for _apply_env_overrides and from_file (+66 tests)#172manus-use wants to merge 6 commits into
manus-use wants to merge 6 commits into
Conversation
added 6 commits
July 10, 2026 08:18
…rom_file (+66 tests) Add tests covering the entire Config environment-variable override pipeline: - MANUS_LLM_PROVIDER/MODEL/BASE_URL/TEMPERATURE/MAX_TOKENS (always-override semantics) - Provider-specific API key resolution (fill-when-None semantics) - AWS region resolution from MANUS_AWS_REGION/AWS_DEFAULT_REGION/AWS_REGION - Integration configs: OTX, GitHub, Lark, Webhooks, MCP env vars - Config.from_file() search-path discovery (CWD, config/, ~/.manus-agent/) - _load_dotenv() file search, priority, override=False behavior - Combined scenarios: full env-only config, partial overrides, empty-string handling - Priority verification: env vars > config.toml > pydantic defaults These 66 tests cover the previously untested _apply_env_overrides() model validator and from_file() configuration loading logic, ensuring that all documented env-var mappings work correctly and that the priority rules (always-override for MANUS_LLM_*, fill-when-None for API keys/tokens) are enforced.
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
Comprehensive test suite for
Config._apply_env_overrides()andConfig.from_file()— the untested configuration loading pipeline that maps environment variables to config fields.What's tested (66 new tests)
MANUS_LLM_* overrides — always-override semantics (12 tests)
MANUS_LLM_PROVIDERalways overrides configured providerMANUS_LLM_MODELalways overrides configured modelMANUS_LLM_BASE_URLalways overrides configured base_urlMANUS_LLM_TEMPERATUREfloat parsing and overrideMANUS_LLM_MAX_TOKENSint parsing and overrideAPI key resolution — fill-when-None semantics (7 tests)
OPENAI_API_KEYfills openai provider key only when NoneANTHROPIC_API_KEYfills anthropic provider key only when NoneAWS region resolution (5 tests)
MANUS_AWS_REGION>AWS_DEFAULT_REGION>AWS_REGIONIntegration configs (15 tests)
MANUS_OTX_API_KEYfill-when-NoneMANUS_GITHUB_TOKEN>GITHUB_TOKENpriorityMANUS_LARK_API_TOKEN>LARK_API_TOKEN, same for document URLMANUS_WEBHOOK_CVE_SUBMIT_URLMANUS_MCP_SERVER_URLConfig.from_file() search paths (7 tests)
config.tomlauto-discoveryconfig/config.tomlfallback~/.manus-agent/config.tomllast resortfrom_file() + env override priority (4 tests)
_load_dotenv() behavior (8 tests)
.envfound and loadedconfig/.envfallback~/.manus-agent/.envfallbackCombined scenarios (3 tests)
Testing approach
mock.patch.dict(os.environ, ...)for isolationtmp_pathandmonkeypatch.chdirfor filesystem testsWhy this matters
_apply_env_overrides()is a Pydantic@model_validatorthat runs on everyConfig()construction — it's the central env→config mapping pipeline. Previously untested, meaning:All 66 tests pass. No existing tests affected.