test: add coverage for config TUI, ConfigField, schema changes, and CLI auto-setup

- test_config.py: GeneralConfig defaults, plugin_settings round-trip
- test_config_field.py: ConfigField dataclass, BasePlugin.config_fields() no-op,
  plugin subclass override
- test_config_tui.py: _get/_set_nested, _fid/_pfid helpers, GENERAL_FIELDS validity,
  ConfigApp general tab rendering, save handler, plugins table, plugin tab visibility,
  q key exit — using Textual run_test() + Pilot
- test_cli.py: auto-setup wizard on first run, skip wizard when config exists,
  /config in _STATIC_COMMANDS

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
curo1305
2026-05-18 21:53:19 +02:00
parent 1201606187
commit 51029d4a2d
4 changed files with 289 additions and 0 deletions
+30
View File
@@ -107,3 +107,33 @@ def test_daemon_commands_exit_cleanly(tmp_pyra_home):
for cmd in ["start", "stop", "status", "restart"]:
result = runner.invoke(main, ["daemon", cmd])
assert result.exit_code == 0, f"daemon {cmd} exited with {result.exit_code}"
def test_main_calls_setup_wizard_when_no_config(tmp_pyra_home, monkeypatch):
setup_calls = []
monkeypatch.setattr("pyra.setup.wizard.run_setup", lambda: setup_calls.append(1))
monkeypatch.setattr("pyra.chat.session.start_chat", lambda: None)
runner = CliRunner()
runner.invoke(main, [])
assert len(setup_calls) == 1, "run_setup should be called once when no config exists"
def test_main_skips_setup_when_config_exists(tmp_pyra_home, monkeypatch):
from pyra.config.manager import save_config
save_config(_make_config())
setup_calls = []
monkeypatch.setattr("pyra.setup.wizard.run_setup", lambda: setup_calls.append(1))
monkeypatch.setattr("pyra.chat.session.start_chat", lambda: None)
runner = CliRunner()
runner.invoke(main, [])
assert len(setup_calls) == 0, "run_setup should NOT be called when config already exists"
def test_config_slash_command_registered():
from pyra.chat.session import _STATIC_COMMANDS
assert "/config" in _STATIC_COMMANDS