Initial upload: Local AI Commit Reviewer CLI with CI/CD workflow
This commit is contained in:
55
tests/unit/test_config.py
Normal file
55
tests/unit/test_config.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import os
|
||||
|
||||
from src.config import Config, ConfigLoader
|
||||
|
||||
|
||||
class TestConfig:
|
||||
def test_default_config(self):
|
||||
config = Config()
|
||||
assert config.llm.endpoint == "http://localhost:11434"
|
||||
assert config.llm.model == "codellama"
|
||||
assert config.review.strictness == "balanced"
|
||||
assert config.hooks.enabled is True
|
||||
|
||||
def test_config_from_dict(self):
|
||||
data = {
|
||||
"llm": {
|
||||
"endpoint": "http://custom:9000",
|
||||
"model": "custom-model"
|
||||
},
|
||||
"review": {
|
||||
"strictness": "strict"
|
||||
}
|
||||
}
|
||||
config = Config(**data)
|
||||
assert config.llm.endpoint == "http://custom:9000"
|
||||
assert config.llm.model == "custom-model"
|
||||
assert config.review.strictness == "strict"
|
||||
|
||||
def test_language_config(self):
|
||||
config = Config()
|
||||
py_config = config.languages.get_language_config("python")
|
||||
assert py_config is not None
|
||||
assert py_config.enabled is True
|
||||
|
||||
def test_strictness_profiles(self):
|
||||
config = Config()
|
||||
permissive = config.strictness_profiles.get_profile("permissive")
|
||||
assert permissive.check_style is False
|
||||
strict = config.strictness_profiles.get_profile("strict")
|
||||
assert strict.check_performance is True
|
||||
|
||||
|
||||
class TestConfigLoader:
|
||||
def test_load_default_config(self):
|
||||
loader = ConfigLoader()
|
||||
config = loader.load()
|
||||
assert isinstance(config, Config)
|
||||
|
||||
def test_find_config_files_nonexistent(self):
|
||||
loader = ConfigLoader("/nonexistent/path.yaml")
|
||||
path, global_path = loader.find_config_files()
|
||||
assert path is None
|
||||
Reference in New Issue
Block a user