Files
shellgenius/tests/test_config.py
7000pctAUTO da5a80a1d6
Some checks failed
CI / test (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / type-check (push) Has been cancelled
Add test files
2026-02-04 11:03:01 +00:00

49 lines
1.5 KiB
Python

"""Tests for configuration module."""
import pytest
import tempfile
import os
from pathlib import Path
from shellgenius.config import Config, get_config
class TestConfig:
def test_default_config(self):
"""Test default configuration values."""
with tempfile.NamedTemporaryFile(mode='w', suffix='.yaml', delete=False) as f:
f.write("")
f.flush()
config = Config(f.name)
assert config.get("ollama.host") == "localhost:11434"
assert config.get("ollama.model") == "codellama"
assert config.get("safety.level") == "moderate"
os.unlink(f.name)
def test_get_nested_value(self):
"""Test getting nested configuration values."""
config = Config()
assert config.get("ollama.host") is not None
assert config.get("nonexistent.key", "default") == "default"
def test_environment_override(self):
"""Test environment variable overrides."""
os.environ["OLLAMA_MODEL"] = "custom-model"
config = Config()
assert config.ollama_model == "custom-model"
del os.environ["OLLAMA_MODEL"]
def test_ollama_properties(self):
"""Test Ollama configuration properties."""
config = Config()
assert "localhost" in config.ollama_host
assert config.ollama_model in ["codellama", "llama2", "mistral"]
assert config.safety_level in ["strict", "moderate", "permissive"]