46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
"""Tests for configuration."""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
import pytest
|
|
|
|
from termflow.config import Config
|
|
from termflow.utils.config import load_config, get_default_db_path
|
|
|
|
|
|
class TestConfig:
|
|
"""Test configuration management."""
|
|
|
|
def test_config_dir_creation(self, tmp_path, monkeypatch):
|
|
"""Test config directory creation."""
|
|
monkeypatch.setenv("TERMFLOW_HOME", str(tmp_path / ".termflow"))
|
|
config = Config()
|
|
assert config.config_dir.exists()
|
|
|
|
def test_default_db_path(self, tmp_path, monkeypatch):
|
|
"""Test default database path."""
|
|
monkeypatch.setenv("TERMFLOW_HOME", str(tmp_path / ".termflow"))
|
|
config = Config()
|
|
assert "sessions.db" in config.db_path
|
|
|
|
def test_git_cache_path(self, tmp_path, monkeypatch):
|
|
"""Test git cache path."""
|
|
monkeypatch.setenv("TERMFLOW_HOME", str(tmp_path / ".termflow"))
|
|
config = Config()
|
|
assert "git_cache" in config.git_cache
|
|
|
|
|
|
class TestConfigUtils:
|
|
"""Test configuration utilities."""
|
|
|
|
def test_load_config_missing(self, tmp_path):
|
|
"""Test loading missing config."""
|
|
result = load_config(str(tmp_path / "missing"))
|
|
assert result == {}
|
|
|
|
def test_get_default_db_path(self):
|
|
"""Test default db path generation."""
|
|
path = get_default_db_path()
|
|
assert "sessions.db" in path
|
|
assert ".termflow" in path
|