pbi-cli/tests/test_config.py
MinaSaad1 51a23668a7 feat: add REPL mode, test suite, CI/CD, and Claude Skills (Sprints 6-8)
Sprint 6 - REPL Mode + Polish:
- Error hierarchy (PbiCliError, McpToolError, etc.) for clean REPL error handling
- Interactive REPL with prompt-toolkit (persistent MCP connection, command completion, history)
- REPL-aware run_tool() and connection commands that reuse shared client
- README.md and CHANGELOG.md

Sprint 7 - Tests + CI/CD:
- 120 tests across unit, command, and e2e test files (79% coverage)
- MockPbiMcpClient with canned responses for test isolation
- GitHub Actions CI (lint + typecheck + test matrix: 3 OS x 3 Python)
- GitHub Actions release workflow for PyPI trusted publishing

Sprint 8 - Claude Skills + Installer:
- 5 bundled SKILL.md files (modeling, dax, deployment, security, docs)
- `pbi skills install/list/uninstall` command for Claude Code discovery
- Skills packaged with wheel via setuptools package-data
2026-03-26 13:54:24 +02:00

63 lines
1.8 KiB
Python

"""Tests for pbi_cli.core.config."""
from __future__ import annotations
import json
from pathlib import Path
from pbi_cli.core.config import PbiConfig, load_config, save_config
def test_default_config() -> None:
config = PbiConfig()
assert config.binary_version == ""
assert config.binary_path == ""
assert config.default_connection == ""
assert config.binary_args == ["--start", "--skipconfirmation"]
def test_with_updates_returns_new_instance() -> None:
original = PbiConfig(binary_version="1.0")
updated = original.with_updates(binary_version="2.0")
assert updated.binary_version == "2.0"
assert original.binary_version == "1.0" # unchanged
def test_with_updates_preserves_other_fields() -> None:
original = PbiConfig(binary_version="1.0", binary_path="/bin/test")
updated = original.with_updates(binary_version="2.0")
assert updated.binary_path == "/bin/test"
def test_load_config_missing_file(tmp_config: Path) -> None:
config = load_config()
assert config.binary_version == ""
assert config.binary_args == ["--start", "--skipconfirmation"]
def test_save_and_load_roundtrip(tmp_config: Path) -> None:
original = PbiConfig(binary_version="0.4.0", binary_path="/test/path")
save_config(original)
loaded = load_config()
assert loaded.binary_version == "0.4.0"
assert loaded.binary_path == "/test/path"
def test_load_config_corrupt_json(tmp_config: Path) -> None:
config_file = tmp_config / "config.json"
config_file.write_text("not valid json{{{", encoding="utf-8")
config = load_config()
assert config.binary_version == "" # falls back to defaults
def test_config_is_frozen() -> None:
config = PbiConfig()
try:
config.binary_version = "new" # type: ignore[misc]
assert False, "Should have raised"
except AttributeError:
pass