The monolithic check_updates.py has been split into the update_monitor/ package with separate modules for fetching, extraction, comparison, classification, and notification. This makes the codebase easier to navigate and test. The flat services.yaml is replaced by per-service directories under services/<name>/config.yaml, co-locating config with update scripts and AI review examples. When --auto-update is enabled, services with an auto-update.sh script get their release notes classified by a local Ollama model (using few-shot examples from review-examples/) to decide whether the update can be applied automatically or needs manual admin intervention. Results are reported in a single consolidated Matrix message. Immich is the first service with auto-update configured, using 7 real release note examples to train the classifier.
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
import sys
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
sys.path.append(str(Path(__file__).resolve().parents[1]))
|
|
|
|
from update_monitor import check_service, load_services
|
|
|
|
|
|
def test_services_extract_current_and_latest():
|
|
services = load_services(
|
|
{
|
|
"services": [
|
|
{
|
|
"name": "CurrentVersion",
|
|
"base_url": "https://example.com/",
|
|
"current_version_url": "https://example.com/current",
|
|
"current_version_extract": {"type": "jsonpath", "value": "$.version"},
|
|
"upstream_latest_version_url": "https://example.com/latest",
|
|
"upstream_latest_extract": {"type": "jsonpath", "value": "$.tag"},
|
|
}
|
|
]
|
|
}
|
|
)
|
|
|
|
responses = {
|
|
"https://example.com/current": "{\"version\": \"1.2.3\"}",
|
|
"https://example.com/latest": "{\"tag\": \"1.2.4\"}",
|
|
}
|
|
|
|
def fake_fetch(url, _timeout, _user_agent, _headers=None, _data=None, _method="GET"):
|
|
return responses[url], {}
|
|
|
|
service = list(services.values())[0]
|
|
with patch("update_monitor.checker.fetch_response", side_effect=fake_fetch):
|
|
result = check_service(service, timeout=5, user_agent="test")
|
|
|
|
assert result["current"] == "1.2.3"
|
|
assert result["latest"] == "1.2.4"
|