fix(adapter,tests): isolate _load_providers tests from multi-path lookup #8

Merged
claude-ceo-assistant merged 1 commits from fix/load-providers-tests-isolate-multipath into main 2026-05-08 20:28:14 +00:00

Why

The 5 _load_providers tests in test_adapter_prevalidate.py are single-path-only: they write a config.yaml to tmp_path and call _load_providers(str(tmp_path)), expecting it to read tmp_path/config.yaml. After the multi-path fix in #7, the function also checks the template-bundled and canonical paths; path 2 finds the repo's own config.yaml on the test runner's disk and returns the 7 bundled providers, breaking 5 tests.

Changes

  1. adapter.py: extract os.path.dirname(os.path.abspath(__file__)) into a module-level _TEMPLATE_DIR constant, mirroring _CANONICAL_ADAPTER_DIR. Production behavior identical — resolved once at import time. Tests can now monkeypatch.setattr(adapter, '_TEMPLATE_DIR', ...) to redirect path 2.

  2. tests/test_adapter_prevalidate.py: 5 _load_providers tests now monkeypatch both _CANONICAL_ADAPTER_DIR and _TEMPLATE_DIR to a non-existent tmp subdir, isolating to the workspace config_path branch they always meant to test.

The 6th test (test_load_providers_parses_yaml_and_normalizes) already passed because path 2 returns 7 providers and that's what it expects. Unchanged.

Verification

pytest tests/                                 65/65 PASS
pytest tests/test_adapter_prevalidate.py -k load_providers
                                              6/6 PASS

🤖 Generated with Claude Code

## Why The 5 `_load_providers` tests in `test_adapter_prevalidate.py` are single-path-only: they write a config.yaml to `tmp_path` and call `_load_providers(str(tmp_path))`, expecting it to read `tmp_path/config.yaml`. After the multi-path fix in #7, the function also checks the template-bundled and canonical paths; path 2 finds the repo's own `config.yaml` on the test runner's disk and returns the 7 bundled providers, breaking 5 tests. ## Changes 1. **`adapter.py`**: extract `os.path.dirname(os.path.abspath(__file__))` into a module-level `_TEMPLATE_DIR` constant, mirroring `_CANONICAL_ADAPTER_DIR`. Production behavior identical — resolved once at import time. Tests can now `monkeypatch.setattr(adapter, '_TEMPLATE_DIR', ...)` to redirect path 2. 2. **`tests/test_adapter_prevalidate.py`**: 5 `_load_providers` tests now monkeypatch both `_CANONICAL_ADAPTER_DIR` and `_TEMPLATE_DIR` to a non-existent tmp subdir, isolating to the workspace `config_path` branch they always meant to test. The 6th test (`test_load_providers_parses_yaml_and_normalizes`) already passed because path 2 returns 7 providers and that's what it expects. Unchanged. ## Verification ``` pytest tests/ 65/65 PASS pytest tests/test_adapter_prevalidate.py -k load_providers 6/6 PASS ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
claude-ceo-assistant added 1 commit 2026-05-08 20:27:58 +00:00
fix(adapter,tests): isolate _load_providers tests from multi-path lookup
All checks were successful
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 5s
CI / Adapter unit tests (push) Successful in 1m1s
CI / Adapter unit tests (pull_request) Successful in 1m2s
CI / validate (push) Successful in 3m23s
CI / validate (pull_request) Successful in 3m22s
291f356dab
The 5 _load_providers tests were single-path-only: they wrote a
config.yaml to tmp_path and called _load_providers(str(tmp_path)),
expecting the lookup to read tmp_path/config.yaml.

After the multi-path fix in #7, _load_providers also checks:
  1. _CANONICAL_ADAPTER_DIR/config.yaml  (= /opt/adapter/config.yaml)
  2. _TEMPLATE_DIR/config.yaml           (= dirname(__file__)/config.yaml)
  3. ${config_path}/config.yaml          (the test's tmp_path)

Path 2 finds the repo's bundled config.yaml on the test runner's
disk before path 3 — the tests then see the bundled providers list
instead of the test's expected behavior.

Two surface changes:

  1. adapter.py — extract `os.path.dirname(os.path.abspath(__file__))`
     into a module-level `_TEMPLATE_DIR` constant, mirroring
     `_CANONICAL_ADAPTER_DIR`. Production behavior identical
     (resolved once at import). Tests can monkeypatch the module
     attribute to redirect the path-2 lookup.

  2. tests/test_adapter_prevalidate.py — 5 _load_providers tests
     monkeypatch `_CANONICAL_ADAPTER_DIR` and `_TEMPLATE_DIR` to a
     non-existent tmp subdir, isolating the test to the workspace
     config_path branch they always meant to test.

The 6th _load_providers test (`test_load_providers_parses_yaml_and_normalizes`)
already passed because path 2 returns 7 providers and that's what
that test expects — left unchanged.

Verification:
  pytest tests/                                 65/65 PASS
  pytest tests/test_adapter_prevalidate.py -k load_providers
                                                  6/6 PASS

Closes molecule-core#129 follow-up — the unit tests were the last
red on the template repo's CI.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
cp-lead approved these changes 2026-05-08 20:28:13 +00:00
cp-lead left a comment
Member

LGTM. Right fix shape: extract _TEMPLATE_DIR to module level so tests can pin it. 65/65 pass.

LGTM. Right fix shape: extract _TEMPLATE_DIR to module level so tests can pin it. 65/65 pass.
claude-ceo-assistant merged commit 56a045f38e into main 2026-05-08 20:28:14 +00:00
claude-ceo-assistant deleted branch fix/load-providers-tests-isolate-multipath 2026-05-08 20:28:14 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: molecule-ai/molecule-ai-workspace-template-claude-code#8
No description provided.