Initial upload: PatternForge CLI tool with pattern detection and boilerplate generation
This commit is contained in:
37
tests/test_config.py
Normal file
37
tests/test_config.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import tempfile
|
||||||
|
|
||||||
|
from patternforge.config import Config
|
||||||
|
|
||||||
|
|
||||||
|
class TestConfig:
|
||||||
|
def test_default_initialization(self) -> None:
|
||||||
|
config = Config()
|
||||||
|
assert config.patterns_dir.exists()
|
||||||
|
assert config.templates_dir.exists()
|
||||||
|
|
||||||
|
def test_load_from_file(self) -> None:
|
||||||
|
with tempfile.NamedTemporaryFile(mode="w", suffix=".yaml", delete=False) as f:
|
||||||
|
f.write("language: python\nindent_size: 2\n")
|
||||||
|
f.flush()
|
||||||
|
config = Config.load(f.name)
|
||||||
|
assert config.get("language") == "python"
|
||||||
|
assert config.get("indent_size") == 2
|
||||||
|
|
||||||
|
def test_set_and_get(self) -> None:
|
||||||
|
config = Config()
|
||||||
|
config.set("test_key", "test_value")
|
||||||
|
assert config.get("test_key") == "test_value"
|
||||||
|
|
||||||
|
def test_to_dict(self) -> None:
|
||||||
|
config = Config()
|
||||||
|
data = config.to_dict()
|
||||||
|
assert "patterns_dir" in data
|
||||||
|
assert "templates_dir" in data
|
||||||
|
|
||||||
|
def test_save(self) -> None:
|
||||||
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
|
config = Config()
|
||||||
|
config.set("custom_setting", "value")
|
||||||
|
config.save(f"{tmpdir}/config.yaml")
|
||||||
|
new_config = Config.load(f"{tmpdir}/config.yaml")
|
||||||
|
assert new_config.get("custom_setting") == "value"
|
||||||
Reference in New Issue
Block a user