import sys sys.path.insert(0, 'bin') from config import load_config, ConfigError import pytest, tempfile, os, yaml def test_load_valid_config(): data = { 'projects': [{'path': '/tmp', 'benchmarks': ['echo ok'], 'time_limit_minutes': 5}], 'token_threshold': {'context_remaining_pct': 60, 'api_budget_usd': 5.0} } with tempfile.NamedTemporaryFile('w', suffix='.yaml', delete=False) as f: yaml.dump(data, f) name = f.name cfg = load_config(name) assert cfg['projects'][0]['time_limit_minutes'] == 5 os.unlink(name) def test_missing_projects_raises(): with tempfile.NamedTemporaryFile('w', suffix='.yaml', delete=False) as f: yaml.dump({}, f) name = f.name with pytest.raises(ConfigError): load_config(name) os.unlink(name) def test_expands_tilde_in_path(): data = { 'projects': [{'path': '~/.claude', 'benchmarks': [], 'time_limit_minutes': 5}], 'token_threshold': {'context_remaining_pct': 60, 'api_budget_usd': 5.0} } with tempfile.NamedTemporaryFile('w', suffix='.yaml', delete=False) as f: yaml.dump(data, f) name = f.name cfg = load_config(name) assert '~' not in cfg['projects'][0]['path'] os.unlink(name)