30 lines
1007 B
Python
30 lines
1007 B
Python
import pytest
|
|
import tempfile
|
|
import os
|
|
from pathlib import Path
|
|
from src.config.config_manager import ConfigManager
|
|
from src.config.settings import Settings
|
|
|
|
|
|
class TestConfigManager:
|
|
def test_load_config_default(self, tmp_path, monkeypatch):
|
|
config_file = tmp_path / "config.json"
|
|
monkeypatch.setenv("DEVDASH_CONFIG", str(config_file))
|
|
manager = ConfigManager()
|
|
config = manager.load_config()
|
|
assert config.refresh_interval == 30
|
|
assert config.theme == "dark"
|
|
|
|
def test_save_and_load_config(self, tmp_path, monkeypatch):
|
|
config_file = tmp_path / "config.json"
|
|
monkeypatch.setenv("DEVDASH_CONFIG", str(config_file))
|
|
manager = ConfigManager()
|
|
settings = Settings(
|
|
github_token="test_token",
|
|
refresh_interval=60,
|
|
)
|
|
manager.save_config(settings)
|
|
loaded = manager.load_config()
|
|
assert loaded.github_token == "test_token"
|
|
assert loaded.refresh_interval == 60
|