# ABOUTME: Tests for configuration loading. # ABOUTME: Verifies TOML parsing, defaults, and path override behavior. from pathlib import Path from moonlock.config import Config, load_config class TestLoadConfig: """Tests for config loading.""" def test_defaults_when_no_config_file(self, tmp_path: Path): nonexistent = tmp_path / "nonexistent.toml" config = load_config(config_paths=[nonexistent]) assert config.background_path is None assert config.fingerprint_enabled is True def test_reads_background_path(self, tmp_path: Path): config_file = tmp_path / "moonlock.toml" config_file.write_text('background_path = "/usr/share/wallpapers/moon.jpg"\n') config = load_config(config_paths=[config_file]) assert config.background_path == "/usr/share/wallpapers/moon.jpg" def test_reads_fingerprint_disabled(self, tmp_path: Path): config_file = tmp_path / "moonlock.toml" config_file.write_text("fingerprint_enabled = false\n") config = load_config(config_paths=[config_file]) assert config.fingerprint_enabled is False def test_later_paths_override_earlier(self, tmp_path: Path): system_conf = tmp_path / "system.toml" system_conf.write_text('background_path = "/system/wallpaper.jpg"\n') user_conf = tmp_path / "user.toml" user_conf.write_text('background_path = "/home/user/wallpaper.jpg"\n') config = load_config(config_paths=[system_conf, user_conf]) assert config.background_path == "/home/user/wallpaper.jpg" def test_partial_config_uses_defaults(self, tmp_path: Path): config_file = tmp_path / "moonlock.toml" config_file.write_text('background_path = "/some/path.jpg"\n') config = load_config(config_paths=[config_file]) assert config.fingerprint_enabled is True