From da5a80a1d61cdd1440845adec6833e966d8f9625 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Wed, 4 Feb 2026 11:03:01 +0000 Subject: [PATCH] Add test files --- tests/test_config.py | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/test_config.py diff --git a/tests/test_config.py b/tests/test_config.py new file mode 100644 index 0000000..a801474 --- /dev/null +++ b/tests/test_config.py @@ -0,0 +1,48 @@ +"""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"]