openwebui-cli/tests/test_config.py
Danny Stocker 8530f74687 Initial CLI scaffolding with v1.0 MVP structure
Complete Python CLI for OpenWebUI with:
- Auth commands (login, logout, whoami, token, refresh)
- Chat send with streaming support
- RAG files/collections management
- Models list/info
- Admin stats (minimal v1.0)
- Config management with profiles and keyring

Stack: typer, httpx, rich, pydantic, keyring

Based on RFC v1.2 with 22-step implementation checklist

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 20:09:19 +01:00

52 lines
1.5 KiB
Python

"""Tests for configuration module."""
import tempfile
from pathlib import Path
import pytest
from openwebui_cli.config import Config, ProfileConfig, load_config, save_config
def test_default_config():
"""Test default configuration values."""
config = Config()
assert config.version == 1
assert config.default_profile == "default"
assert "default" in config.profiles
assert config.defaults.format == "text"
assert config.defaults.stream is True
assert config.defaults.timeout == 30
def test_profile_config():
"""Test profile configuration."""
profile = ProfileConfig(uri="https://example.com")
assert profile.uri == "https://example.com"
def test_config_roundtrip(tmp_path, monkeypatch):
"""Test saving and loading config."""
config_dir = tmp_path / "openwebui"
config_path = config_dir / "config.yaml"
# Monkey-patch the config path functions
monkeypatch.setattr("openwebui_cli.config.get_config_dir", lambda: config_dir)
monkeypatch.setattr("openwebui_cli.config.get_config_path", lambda: config_path)
# Create and save config
config = Config(
default_profile="test",
profiles={"test": ProfileConfig(uri="https://test.example.com")},
)
config.defaults.model = "test-model"
save_config(config)
# Load and verify
loaded = load_config()
assert loaded.default_profile == "test"
assert loaded.profiles["test"].uri == "https://test.example.com"
assert loaded.defaults.model == "test-model"