feat: check source links during scheduled fetches
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
from urllib.error import HTTPError
|
||||
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from app.community_scheduler import MAX_BACKOFF_SECONDS, configured_sources, _static_registry, oldest_site_source, retry_delay
|
||||
from app.config import Settings
|
||||
from app.source_lifecycle import classify_source_failure
|
||||
|
||||
|
||||
def test_all_authorized_sources_are_scheduled() -> None:
|
||||
@@ -23,6 +25,16 @@ def test_failed_runs_back_off_but_success_resets_delay() -> None:
|
||||
assert retry_delay(["success", "failed"]) == 1800
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("code", "expected"), [(404, "missing"), (410, "missing"), (403, "blocked"), (429, "blocked"), (500, "temporary_error")])
|
||||
def test_source_http_failure_classification(code: int, expected: str) -> None:
|
||||
error = HTTPError("https://rf4.example/source", code, "failure", {}, None)
|
||||
assert classify_source_failure(error) == expected
|
||||
|
||||
|
||||
def test_non_http_source_failure_is_temporary() -> None:
|
||||
assert classify_source_failure(TimeoutError("timeout")) == "temporary_error"
|
||||
|
||||
|
||||
def test_same_site_endpoints_rotate_by_oldest_attempt() -> None:
|
||||
now = datetime.now(timezone.utc)
|
||||
all_keys = {"rf4db", "rf4stat-fishing", "rf4stat-post", "rf4map", "rf4posts-spot"}
|
||||
|
||||
Reference in New Issue
Block a user