30 lines
830 B
Python
30 lines
830 B
Python
"""Tests for history_sync task registration."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
from app.tasks import history_sync
|
|
|
|
|
|
class TestHistorySyncTask:
|
|
async def test_register_schedules_job(self) -> None:
|
|
fake_scheduler = MagicMock()
|
|
class FakeState:
|
|
pass
|
|
|
|
class FakeSettings:
|
|
fail2ban_socket = "/tmp/fake.sock"
|
|
|
|
app = type("FakeApp", (), {})()
|
|
app.state = FakeState()
|
|
app.state.scheduler = fake_scheduler
|
|
app.state.settings = FakeSettings()
|
|
|
|
history_sync.register(app)
|
|
|
|
fake_scheduler.add_job.assert_called_once()
|
|
called_args, called_kwargs = fake_scheduler.add_job.call_args
|
|
assert called_kwargs["id"] == history_sync.JOB_ID
|
|
assert called_kwargs["kwargs"]["app"] == app
|