fix: enforce community cooldown per site
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from app.community_scheduler import MAX_BACKOFF_SECONDS, configured_sources, retry_delay
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from app.community_scheduler import MAX_BACKOFF_SECONDS, configured_sources, oldest_site_source, retry_delay
|
||||
from app.config import Settings
|
||||
|
||||
|
||||
@@ -19,3 +21,10 @@ def test_failed_runs_back_off_but_success_resets_delay() -> None:
|
||||
assert retry_delay(["failed", "failed", "failed"]) == 7200
|
||||
assert retry_delay(["failed"] * 20) == MAX_BACKOFF_SECONDS
|
||||
assert retry_delay(["success", "failed"]) == 1800
|
||||
|
||||
|
||||
def test_same_site_endpoints_rotate_by_oldest_attempt() -> None:
|
||||
now = datetime.now(timezone.utc)
|
||||
assert oldest_site_source("rf4stat-fishing", {}) == "rf4stat-fishing"
|
||||
latest = {"rf4stat-fishing": now, "rf4stat-post": now - timedelta(hours=1)}
|
||||
assert oldest_site_source("rf4stat-fishing", latest) == "rf4stat-post"
|
||||
|
||||
Reference in New Issue
Block a user