add vps check

This commit is contained in:
qananasikq
2026-04-24 18:36:58 +03:00
parent 31f87a9bdf
commit f8206615a9
5 changed files with 88 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
from __future__ import annotations
import json
import unittest
from unittest.mock import MagicMock, patch
@@ -50,6 +51,27 @@ class TestSelfHeal(unittest.TestCase):
self.assertIsNone(ts)
def test_active_recent_progress_prevents_db_idle_restart(self) -> None:
redis_client = MagicMock()
redis_client.scan_iter.return_value = ["iaai:state:task_progress:hourly"]
redis_client.get.return_value = json.dumps(
{
"task_id": "hourly",
"stage": "fast_listing_collected",
"ts": 1000,
"last_db_progress_ts": 1,
"skipped_existing": 2417,
}
)
active = self_heal._has_active_recent_progress(
redis_client,
now_ts=1010,
stall_seconds=900,
)
self.assertTrue(active)
@patch("iaai_scraper.worker.self_heal.time.sleep", return_value=None)
@patch("iaai_scraper.worker.self_heal.os.kill")
@patch("builtins.open")

View File

@@ -19,6 +19,8 @@ class TestWorkerTaskLockHelpers(unittest.TestCase):
settings = Settings(runtime_config_file=runtime_config_file)
settings.listing.listing_segments_json = "runtime"
settings.scraping_profile.http_first = False
settings.listing.fast_segment_year_splits = True
segs = tasks._build_listing_segments(settings)