-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
46 lines (35 loc) · 1.24 KB
/
conftest.py
File metadata and controls
46 lines (35 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Configuration for all tests."""
import pathlib
from typing import Any, Dict
import msgspec
import pytest
from deskmaid import __author__
from deskmaid.config import Config, TemplatePath
from deskmaid.deskmaid import Deskmaid
from deskmaid.file import get_root_directory
@pytest.fixture(autouse=True)
def _add_author(doctest_namespace: Dict[str, Any]) -> None:
"""Update doctest namespace."""
doctest_namespace["author"] = __author__
@pytest.fixture()
def resources() -> pathlib.Path:
"""Get resources folder."""
return pathlib.Path(__file__).parent / "tests" / "resources"
@pytest.fixture()
def config() -> Config:
"""Get config."""
path = get_root_directory() / "config" / "config.yml"
content = path.read_bytes()
return msgspec.yaml.decode(content, type=Config)
@pytest.fixture()
def deskmaid(tmp_path: pathlib.Path) -> Deskmaid:
"""Get config."""
deskmaid = Deskmaid.load(dry_run=True)
desktop = tmp_path / "desktop"
desktop.mkdir(parents=True, exist_ok=True)
deskmaid.config.desktop = TemplatePath(str(desktop))
deskmaid.config.storage = TemplatePath(str(tmp_path / "storage"))
deskmaid.config.storage = TemplatePath(
str(tmp_path / "cache" / "latest.jsonl"),
)
return deskmaid