Crea servizio watchdog configurabile

This commit is contained in:
2026-06-30 20:28:02 +02:00
parent 124cc370e5
commit 4dca5fbf95
17 changed files with 904 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
from __future__ import annotations
from pathlib import Path
from bakrest.config import parse_config
from bakrest.filters import WatchFilter
def test_parse_config_normalizes_extensions(tmp_path: Path) -> None:
config = parse_config(
{
"watch": {
"include_dirs": [str(tmp_path)],
"include_extensions": ["jpg", ".PNG"],
"exclude_dirs": [],
"exclude_patterns": [],
}
},
tmp_path / "config.toml",
)
assert config.watch.include_extensions == frozenset({".jpg", ".png"})
def test_filter_accepts_included_extension(tmp_path: Path) -> None:
config = parse_config(
{
"watch": {
"include_dirs": [str(tmp_path)],
"include_extensions": [".jpg"],
"exclude_dirs": [],
"exclude_patterns": [],
}
},
tmp_path / "config.toml",
)
assert WatchFilter(config.watch).should_track(tmp_path / "image.jpg")
def test_filter_rejects_excluded_pattern(tmp_path: Path) -> None:
config = parse_config(
{
"watch": {
"include_dirs": [str(tmp_path)],
"include_extensions": [".jpg"],
"exclude_dirs": [],
"exclude_patterns": ["~$*"],
}
},
tmp_path / "config.toml",
)
assert not WatchFilter(config.watch).should_track(tmp_path / "~$image.jpg")