41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
from iaai_sync_service.runtime_config import RuntimeConfig, load_runtime_config
|
|
|
|
|
|
def test_load_runtime_config_reads_filters(tmp_path) -> None: # noqa: ANN001
|
|
config_path = tmp_path / "sync_runtime_config.json"
|
|
config_path.write_text(
|
|
json.dumps(
|
|
{
|
|
"sync": {
|
|
"condition_check_enabled": "true",
|
|
},
|
|
"filters": {
|
|
"brands": ["Acura", "BMW"],
|
|
"models": ["RSX", "3 SERIES"],
|
|
"years": [2021, "2022"],
|
|
"body_types": ["SUV"],
|
|
},
|
|
}
|
|
),
|
|
encoding="utf-8",
|
|
)
|
|
|
|
runtime = load_runtime_config(config_path)
|
|
assert runtime.condition_check_enabled is True
|
|
assert runtime.filters.brands == {"acura", "bmw"}
|
|
assert runtime.filters.models == {"rsx", "3 series"}
|
|
assert runtime.filters.years == {2021, 2022}
|
|
assert runtime.filters.body_types == {"suv"}
|
|
|
|
|
|
def test_load_runtime_config_returns_defaults_on_invalid_json(tmp_path) -> None: # noqa: ANN001
|
|
config_path = tmp_path / "sync_runtime_config.json"
|
|
config_path.write_text("{invalid", encoding="utf-8")
|
|
|
|
runtime = load_runtime_config(config_path)
|
|
assert runtime == RuntimeConfig()
|