import os from spoc import config TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), 'test_data') with open(os.path.join(TEST_DATA_DIR, 'spoc.conf')) as f: MOCK_CONFIG = f.read() def test_config(): config_file = os.path.join(os.path.dirname(__file__), 'test_data/spoc.conf') config.reload(config_file) assert config.DATA_DIR == '/some/data/dir' assert config.AUTOSTART_FILE == '/some/data/dir/autostart' assert config.REPO_BASE_URL == 'https://user:pass@example.com/spoc' assert config.REPO_FILE_URL == 'https://user:pass@example.com/spoc/repository.json' def test_default_config(): config_file = os.path.join(os.path.dirname(__file__), 'test_data/nonexistent') config.reload(config_file) assert config.DATA_DIR == '/var/lib/spoc' assert config.AUTOSTART_FILE == '/var/lib/spoc/autostart' assert config.REPO_BASE_URL == 'https://localhost' assert config.REPO_FILE_URL == 'https://localhost/repository.json'