plano/cli/test/test_init.py
Adil Hafeez 5a4f8cb321
Standardize demo configs and CLI templates to v0.3.0
- Update all demo config files to version v0.3.0
- Rename llm_providers → model_providers across all configs
- Modernize listener format from object to array style
  (e.g. listeners: [{type: model, name:, port:}])
- Replace chatbot_ui with AnythingLLM in 6 docker-compose files
- Remove prometheus/grafana services from llm_gateway and
  preference_based_routing docker-compose files
- Add tracing: random_sampling: 100 to configs that lacked it
- Update 3 CLI init templates (coding_agent_routing,
  preference_aware_routing, conversational_state_v1_responses)
- Fix test_init.py assertion for model_providers key

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 01:43:59 -08:00

51 lines
1.5 KiB
Python

from click.testing import CliRunner
from planoai.init_cmd import init
def test_init_clean_writes_empty_config(tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
runner = CliRunner()
result = runner.invoke(init, ["--clean"])
assert result.exit_code == 0, result.output
config_path = tmp_path / "config.yaml"
assert config_path.exists()
assert config_path.read_text(encoding="utf-8") == "\n"
def test_init_template_builtin_writes_config(tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
runner = CliRunner()
result = runner.invoke(init, ["--template", "coding_agent_routing"])
assert result.exit_code == 0, result.output
config_path = tmp_path / "config.yaml"
assert config_path.exists()
config_text = config_path.read_text(encoding="utf-8")
assert "model_providers:" in config_text
def test_init_refuses_overwrite_without_force(tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
(tmp_path / "config.yaml").write_text("hello", encoding="utf-8")
runner = CliRunner()
result = runner.invoke(init, ["--clean"])
assert result.exit_code != 0
assert "Refusing to overwrite" in result.output
def test_init_force_overwrites(tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
(tmp_path / "config.yaml").write_text("hello", encoding="utf-8")
runner = CliRunner()
result = runner.invoke(init, ["--clean", "--force"])
assert result.exit_code == 0, result.output
assert (tmp_path / "config.yaml").read_text(encoding="utf-8") == "\n"