From 7be7922b08b5729b11f63b30a750be0c26043e9b Mon Sep 17 00:00:00 2001 From: Kharec Date: Tue, 23 Dec 2025 04:49:13 +0100 Subject: [PATCH] test: cover config load and errors --- tests/test_configure_load.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/test_configure_load.py diff --git a/tests/test_configure_load.py b/tests/test_configure_load.py new file mode 100644 index 0000000..6a487b8 --- /dev/null +++ b/tests/test_configure_load.py @@ -0,0 +1,32 @@ +from pathlib import Path + +import pytest + +from skywipe.configure import Configuration + + +def test_configuration_load_missing_file(monkeypatch, tmp_path): + monkeypatch.setattr(Path, "home", lambda: tmp_path) + config = Configuration() + with pytest.raises(FileNotFoundError): + config.load() + + +def test_configuration_load_empty_file(monkeypatch, tmp_path): + monkeypatch.setattr(Path, "home", lambda: tmp_path) + config = Configuration() + config.config_file.parent.mkdir(parents=True, exist_ok=True) + config.config_file.write_text("") + + with pytest.raises(ValueError, match="empty or invalid"): + config.load() + + +def test_configuration_load_invalid_yaml(monkeypatch, tmp_path): + monkeypatch.setattr(Path, "home", lambda: tmp_path) + config = Configuration() + config.config_file.parent.mkdir(parents=True, exist_ok=True) + config.config_file.write_text(": bad") + + with pytest.raises(ValueError, match="Invalid YAML"): + config.load()