Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
"""Config and facility list tests (no browser)."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
SRC = ROOT / "src"
|
|
sys.path.insert(0, str(SRC))
|
|
|
|
from config import ( # noqa: E402
|
|
read_app_config,
|
|
read_facility_list,
|
|
read_onedrive_config,
|
|
)
|
|
from onedrive_planner import _sanitize_folder_name, _xpath_literal # noqa: E402
|
|
|
|
|
|
@pytest.fixture
|
|
def example_config() -> Path:
|
|
path = ROOT / "Input" / "input.xlsx.example"
|
|
assert path.exists(), f"Missing template: {path}"
|
|
return path
|
|
|
|
|
|
def test_helpers() -> None:
|
|
assert _sanitize_folder_name("Test/Facility") == "Test_Facility"
|
|
assert _xpath_literal("Plain Name") == "'Plain Name'"
|
|
assert "concat" in _xpath_literal('O\'Brien "East" Wing')
|
|
|
|
|
|
def test_read_facility_list_skips_placeholder(example_config: Path) -> None:
|
|
facilities = read_facility_list(example_config, warn_if_not_expected_count=False)
|
|
assert facilities
|
|
assert not any("REPLACE_WITH" in f for f in facilities)
|
|
|
|
|
|
def test_read_app_config_planner_url(example_config: Path) -> None:
|
|
cfg = read_app_config(example_config)
|
|
assert "planner.cloud.microsoft" in cfg.planner_url
|
|
|
|
|
|
def test_read_onedrive_config_tuple_length(example_config: Path) -> None:
|
|
row = read_onedrive_config(example_config)
|
|
assert len(row) == 10
|
|
assert "planner.cloud.microsoft" in row[9]
|