Supporta utente target per percorsi watchdog
This commit is contained in:
@@ -22,6 +22,25 @@ def test_parse_config_normalizes_extensions(tmp_path: Path) -> None:
|
||||
assert config.watch.include_extensions == frozenset({".jpg", ".png"})
|
||||
|
||||
|
||||
def test_parse_config_expands_watch_paths_for_target_user(tmp_path: Path) -> None:
|
||||
config = parse_config(
|
||||
{
|
||||
"watch": {
|
||||
"target_user": "pettirosso",
|
||||
"include_dirs": ["%USERPROFILE%\\Documents"],
|
||||
"include_extensions": [".docx"],
|
||||
"exclude_dirs": ["%APPDATA%"],
|
||||
"exclude_patterns": [],
|
||||
}
|
||||
},
|
||||
tmp_path / "config.toml",
|
||||
)
|
||||
|
||||
assert config.watch.target_user == "pettirosso"
|
||||
assert config.watch.include_dirs == (Path("C:/Users/pettirosso/Documents"),)
|
||||
assert config.watch.exclude_dirs == (Path("C:/Users/pettirosso/AppData/Roaming"),)
|
||||
|
||||
|
||||
def test_parse_config_reads_multiple_remote_destinations(tmp_path: Path) -> None:
|
||||
config = parse_config(
|
||||
{
|
||||
|
||||
23
tests/test_paths.py
Normal file
23
tests/test_paths.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from bakrest.paths import expand_path
|
||||
|
||||
|
||||
def test_expand_path_uses_target_user_for_userprofile() -> None:
|
||||
assert expand_path("%USERPROFILE%\\Documents", "pettirosso") == Path(
|
||||
"C:/Users/pettirosso/Documents"
|
||||
)
|
||||
|
||||
|
||||
def test_expand_path_uses_target_user_for_appdata() -> None:
|
||||
assert expand_path("%APPDATA%\\Microsoft", ".\\pettirosso") == Path(
|
||||
"C:/Users/pettirosso/AppData/Roaming/Microsoft"
|
||||
)
|
||||
|
||||
|
||||
def test_expand_path_uses_target_user_for_temp() -> None:
|
||||
assert expand_path("%TEMP%", "pettirosso") == Path(
|
||||
"C:/Users/pettirosso/AppData/Local/Temp"
|
||||
)
|
||||
Reference in New Issue
Block a user