mirror of
https://github.com/zvx-echo6/central.git
synced 2026-05-22 10:34:43 +02:00
Merge pull request #51 from zvx-echo6/chore/lint-cleanup-test-imports
chore(lint-cleanup): remove 10 pre-existing ruff issues in 4 test files
This commit is contained in:
commit
d0375225b2
2 changed files with 4 additions and 25 deletions
|
|
@ -5,7 +5,7 @@ import base64
|
||||||
import os
|
import os
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import AsyncMock, MagicMock, patch
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import asyncpg
|
import asyncpg
|
||||||
import pytest
|
import pytest
|
||||||
|
|
@ -206,10 +206,7 @@ class TestRateLimitGuarantee:
|
||||||
state.config = new_config
|
state.config = new_config
|
||||||
state.adapter.cadence_s = 90
|
state.adapter.cadence_s = 90
|
||||||
|
|
||||||
# Calculate expected next poll time
|
|
||||||
expected_next_poll = last_poll + timedelta(seconds=90)
|
|
||||||
now = datetime.now(timezone.utc)
|
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
|
# The wait time should be based on last_poll + new_cadence
|
||||||
# Since last_poll was 30 seconds ago and new cadence is 90,
|
# 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,
|
If operator increases cadence to 120s after a gap of 150s,
|
||||||
the poll should happen now (not wait another 120s).
|
the poll should happen now (not wait another 120s).
|
||||||
"""
|
"""
|
||||||
from central.supervisor import AdapterState
|
|
||||||
|
|
||||||
mock_adapter = MagicMock()
|
mock_adapter = MagicMock()
|
||||||
mock_adapter.name = "test"
|
mock_adapter.name = "test"
|
||||||
|
|
@ -248,13 +244,6 @@ class TestRateLimitGuarantee:
|
||||||
updated_at=datetime.now(timezone.utc),
|
updated_at=datetime.now(timezone.utc),
|
||||||
)
|
)
|
||||||
|
|
||||||
state = AdapterState(
|
|
||||||
name="test",
|
|
||||||
adapter=mock_adapter,
|
|
||||||
config=config,
|
|
||||||
last_completed_poll=last_poll,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Calculate next poll time
|
# Calculate next poll time
|
||||||
now = datetime.now(timezone.utc)
|
now = datetime.now(timezone.utc)
|
||||||
next_poll_at = last_poll.timestamp() + config.cadence_s
|
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
|
poll should be at (last_completed_poll + cadence_s), not immediately
|
||||||
(unless that time has already passed).
|
(unless that time has already passed).
|
||||||
"""
|
"""
|
||||||
from central.supervisor import AdapterState
|
|
||||||
|
|
||||||
mock_adapter = MagicMock()
|
mock_adapter = MagicMock()
|
||||||
mock_adapter.name = "test"
|
mock_adapter.name = "test"
|
||||||
|
|
@ -293,13 +281,6 @@ class TestRateLimitGuarantee:
|
||||||
updated_at=datetime.now(timezone.utc),
|
updated_at=datetime.now(timezone.utc),
|
||||||
)
|
)
|
||||||
|
|
||||||
state = AdapterState(
|
|
||||||
name="test",
|
|
||||||
adapter=mock_adapter,
|
|
||||||
config=config,
|
|
||||||
last_completed_poll=last_poll,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Calculate next poll time
|
# Calculate next poll time
|
||||||
now = datetime.now(timezone.utc)
|
now = datetime.now(timezone.utc)
|
||||||
next_poll_at = last_poll.timestamp() + config.cadence_s
|
next_poll_at = last_poll.timestamp() + config.cadence_s
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,13 @@ IMPORTANT: These tests are designed to:
|
||||||
- PASS on fixed code (last_completed_poll is preserved across disable/enable)
|
- PASS on fixed code (last_completed_poll is preserved across disable/enable)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import AsyncMock, MagicMock, patch
|
from unittest.mock import AsyncMock, MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import pytest_asyncio
|
|
||||||
|
|
||||||
from central.config_models import AdapterConfig
|
from central.config_models import AdapterConfig
|
||||||
from central.bootstrap_config import get_settings
|
from central.bootstrap_config import get_settings
|
||||||
|
|
@ -195,7 +193,7 @@ class TestEnableDisableEnableIntegration:
|
||||||
- Assert next poll fires immediately (last+cadence is in past)
|
- Assert next poll fires immediately (last+cadence is in past)
|
||||||
- Assert exactly ONE poll happens, not multiple catch-up
|
- Assert exactly ONE poll happens, not multiple catch-up
|
||||||
"""
|
"""
|
||||||
from central.supervisor import Supervisor, AdapterState
|
from central.supervisor import Supervisor
|
||||||
|
|
||||||
config_source = MockConfigSource()
|
config_source = MockConfigSource()
|
||||||
initial_config = AdapterConfig(
|
initial_config = AdapterConfig(
|
||||||
|
|
@ -306,7 +304,7 @@ class TestEnableDisableEnableIntegration:
|
||||||
- Re-enable adapter 20 seconds later (still within cadence window)
|
- Re-enable adapter 20 seconds later (still within cadence window)
|
||||||
- Assert next poll fires at last_poll + 60s, NOT immediately
|
- Assert next poll fires at last_poll + 60s, NOT immediately
|
||||||
"""
|
"""
|
||||||
from central.supervisor import Supervisor, AdapterState
|
from central.supervisor import Supervisor
|
||||||
|
|
||||||
config_source = MockConfigSource()
|
config_source = MockConfigSource()
|
||||||
initial_config = AdapterConfig(
|
initial_config = AdapterConfig(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue