Files
Pyra/tests/unit/test_config_dirs.py
curo1305 6bb7c77692 test: add comprehensive coverage for cli, chat, renderer, dirs, install, paths
56 new tests covering previously untested modules:
- test_cli.py: memory write/read/append/list + plugin enable/disable + daemon stubs (via CliRunner)
- test_chat_history.py: ConversationHistory build_for_api, add_*/clear, _trim_to_budget
- test_chat_renderer.py: render_text_response return values, void render_* functions
- test_config_dirs.py: bootstrap idempotency, directory/template/vault/db creation
- test_plugin_install.py: list_bundled_plugins, read_manifest, install_bundled_plugin
- test_utils_paths.py: ensure_dir (nested, idempotent), safe_chmod

Total: 171 → 227 passing tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 20:16:25 +02:00

51 lines
1.7 KiB
Python

import os
def test_bootstrap_idempotent(tmp_pyra_home):
from pyra.config.dirs import bootstrap
bootstrap() # already called by fixture; should not raise
def test_bootstrap_creates_all_directories(tmp_pyra_home):
assert (tmp_pyra_home / "memory" / "user").is_dir()
assert (tmp_pyra_home / "memory" / "context").is_dir()
assert (tmp_pyra_home / "memory" / "knowledge").is_dir()
assert (tmp_pyra_home / "vault" / "secrets").is_dir()
assert (tmp_pyra_home / "plugins").is_dir()
assert (tmp_pyra_home / "logs").is_dir()
def test_bootstrap_creates_template_files(tmp_pyra_home):
from pyra.config.dirs import bootstrap
bootstrap()
assert (tmp_pyra_home / "memory" / "MEMORY_INDEX.md").exists()
assert (tmp_pyra_home / "memory" / "user" / "profile.md").exists()
def test_bootstrap_template_content(tmp_pyra_home):
from pyra.config.dirs import bootstrap
bootstrap()
profile = (tmp_pyra_home / "memory" / "user" / "profile.md").read_text()
assert "User Profile" in profile
def test_bootstrap_initializes_db(tmp_pyra_home):
from pyra.memory import database
assert database._DB_PATH.exists()
def test_bootstrap_creates_vault_lock(tmp_pyra_home):
assert (tmp_pyra_home / "vault" / ".vault_lock").exists()
def test_bootstrap_sets_config_permissions(tmp_pyra_home):
from pyra.config.manager import save_config
from pyra.config.schema import PyraConfig, ProviderConfig
from pyra.config.dirs import bootstrap
save_config(PyraConfig(ai=ProviderConfig(provider_id="lmstudio", model="gemma")))
bootstrap()
config = tmp_pyra_home / "config.yaml"
assert config.exists()
if os.name != "nt":
assert oct(config.stat().st_mode)[-3:] == "600"