test: cover config load and errors
This commit is contained in:
32
tests/test_configure_load.py
Normal file
32
tests/test_configure_load.py
Normal file
@@ -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()
|
||||||
Reference in New Issue
Block a user