From ff3d9bb3c3e2bc55b0df90c151ee58f3ff252407 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Thu, 21 May 2026 18:20:18 +0000 Subject: [PATCH] chore(lint-cleanup): remove 10 pre-existing ruff issues in 4 test files Cleans up unused imports and dead locals flagged by ruff in the test files PR #50 (M-b) touched. Tests-only; no production code, no service restart. - test_supervisor_hotreload.py: drop unused AsyncMock/patch imports, dead expected_wait/expected_next_poll locals, and two dead state = AdapterState(...) blocks plus their now-orphaned local imports - test_supervisor_integration.py: drop unused asyncio/patch/pytest_asyncio imports and AdapterState from two function-local imports ruff tests/ 92 -> 82 (the 4 named files now 0; all other files unchanged). Full suite: 590 passed, 1 skipped (central and unprivileged zvx). Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/test_supervisor_hotreload.py | 21 +-------------------- tests/test_supervisor_integration.py | 8 +++----- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/tests/test_supervisor_hotreload.py b/tests/test_supervisor_hotreload.py index 10343b8..9fa40af 100644 --- a/tests/test_supervisor_hotreload.py +++ b/tests/test_supervisor_hotreload.py @@ -5,7 +5,7 @@ import base64 import os from datetime import datetime, timedelta, timezone from pathlib import Path -from unittest.mock import AsyncMock, MagicMock, patch +from unittest.mock import MagicMock import asyncpg import pytest @@ -206,10 +206,7 @@ class TestRateLimitGuarantee: state.config = new_config state.adapter.cadence_s = 90 - # Calculate expected next poll time - expected_next_poll = last_poll + timedelta(seconds=90) now = datetime.now(timezone.utc) - expected_wait = max(0, (expected_next_poll - now).total_seconds()) # The wait time should be based on last_poll + new_cadence # Since last_poll was 30 seconds ago and new cadence is 90, @@ -230,7 +227,6 @@ class TestRateLimitGuarantee: If operator increases cadence to 120s after a gap of 150s, the poll should happen now (not wait another 120s). """ - from central.supervisor import AdapterState mock_adapter = MagicMock() mock_adapter.name = "test" @@ -248,13 +244,6 @@ class TestRateLimitGuarantee: updated_at=datetime.now(timezone.utc), ) - state = AdapterState( - name="test", - adapter=mock_adapter, - config=config, - last_completed_poll=last_poll, - ) - # Calculate next poll time now = datetime.now(timezone.utc) next_poll_at = last_poll.timestamp() + config.cadence_s @@ -274,7 +263,6 @@ class TestRateLimitGuarantee: poll should be at (last_completed_poll + cadence_s), not immediately (unless that time has already passed). """ - from central.supervisor import AdapterState mock_adapter = MagicMock() mock_adapter.name = "test" @@ -293,13 +281,6 @@ class TestRateLimitGuarantee: updated_at=datetime.now(timezone.utc), ) - state = AdapterState( - name="test", - adapter=mock_adapter, - config=config, - last_completed_poll=last_poll, - ) - # Calculate next poll time now = datetime.now(timezone.utc) next_poll_at = last_poll.timestamp() + config.cadence_s diff --git a/tests/test_supervisor_integration.py b/tests/test_supervisor_integration.py index 517dbe5..47b5b58 100644 --- a/tests/test_supervisor_integration.py +++ b/tests/test_supervisor_integration.py @@ -9,15 +9,13 @@ IMPORTANT: These tests are designed to: - PASS on fixed code (last_completed_poll is preserved across disable/enable) """ -import asyncio import base64 import os from datetime import datetime, timedelta, timezone from pathlib import Path -from unittest.mock import AsyncMock, MagicMock, patch +from unittest.mock import AsyncMock, MagicMock import pytest -import pytest_asyncio from central.config_models import AdapterConfig from central.bootstrap_config import get_settings @@ -195,7 +193,7 @@ class TestEnableDisableEnableIntegration: - Assert next poll fires immediately (last+cadence is in past) - Assert exactly ONE poll happens, not multiple catch-up """ - from central.supervisor import Supervisor, AdapterState + from central.supervisor import Supervisor config_source = MockConfigSource() initial_config = AdapterConfig( @@ -306,7 +304,7 @@ class TestEnableDisableEnableIntegration: - Re-enable adapter 20 seconds later (still within cadence window) - Assert next poll fires at last_poll + 60s, NOT immediately """ - from central.supervisor import Supervisor, AdapterState + from central.supervisor import Supervisor config_source = MockConfigSource() initial_config = AdapterConfig(