mirror of
https://github.com/pyMC-dev/pyMC_Repeater.git
synced 2026-08-07 01:13:11 +02:00
fix: streamline cleanup_old_data calls by consolidating argument formatting
This commit is contained in:
+2
-6
@@ -1706,13 +1706,9 @@ class RepeaterHandler(BaseHandler):
|
||||
if current_time - self.last_db_cleanup >= 21600:
|
||||
if self.storage:
|
||||
try:
|
||||
retention_cfg = self.config.get("storage", {}).get(
|
||||
"retention", {}
|
||||
)
|
||||
retention_cfg = self.config.get("storage", {}).get("retention", {})
|
||||
retention_days = retention_cfg.get("sqlite_cleanup_days", 31)
|
||||
companion_events_days = retention_cfg.get(
|
||||
"companion_events_days", 31
|
||||
)
|
||||
companion_events_days = retention_cfg.get("companion_events_days", 31)
|
||||
self.storage.cleanup_old_data(
|
||||
days=retention_days,
|
||||
companion_events_days=companion_events_days,
|
||||
|
||||
@@ -2774,9 +2774,7 @@ class TestEngineTransmissionAndBackgroundLifecycle:
|
||||
handler._record_crc_errors_async.assert_awaited_once()
|
||||
handler._send_periodic_advert_async.assert_awaited_once()
|
||||
handler.cleanup_cache.assert_called_once()
|
||||
handler.storage.cleanup_old_data.assert_called_once_with(
|
||||
days=31, companion_events_days=31
|
||||
)
|
||||
handler.storage.cleanup_old_data.assert_called_once_with(days=31, companion_events_days=31)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_background_timer_loop_continues_when_db_cleanup_fails(self, handler):
|
||||
|
||||
@@ -20,9 +20,7 @@ def _bare_collector() -> StorageCollector:
|
||||
def test_cleanup_passes_companion_events_days_through():
|
||||
collector = _bare_collector()
|
||||
collector.cleanup_old_data(days=10, companion_events_days=20)
|
||||
collector.sqlite_handler.cleanup_old_data.assert_called_once_with(
|
||||
10, companion_events_days=20
|
||||
)
|
||||
collector.sqlite_handler.cleanup_old_data.assert_called_once_with(10, companion_events_days=20)
|
||||
|
||||
|
||||
def test_cleanup_defaults_match_engine_callsite():
|
||||
@@ -30,6 +28,4 @@ def test_cleanup_defaults_match_engine_callsite():
|
||||
# for any older callers that only know about ``days``.
|
||||
collector = _bare_collector()
|
||||
collector.cleanup_old_data(days=7)
|
||||
collector.sqlite_handler.cleanup_old_data.assert_called_once_with(
|
||||
7, companion_events_days=None
|
||||
)
|
||||
collector.sqlite_handler.cleanup_old_data.assert_called_once_with(7, companion_events_days=None)
|
||||
|
||||
Reference in New Issue
Block a user