"""Tests for app/tasks/worker.py"""

from app.tasks.worker import (
    WorkerSettings,
    startup,
    shutdown,
)


class TestWorkerSettings:
    def test_worker_settings_has_functions(self):
        assert len(WorkerSettings.functions) >= 4

    def test_worker_settings_has_cron_jobs(self):
        assert len(WorkerSettings.cron_jobs) >= 4

    def test_worker_settings_functions_are_callable(self):
        for func in WorkerSettings.functions:
            assert callable(func)

    def test_worker_settings_cron_jobs_have_valid_crontab(self):
        for job in WorkerSettings.cron_jobs:
            # minute is always required; hour can be None (runs every hour)
            assert job.minute is not None

    def test_startup_and_shutdown_exist(self):
        assert WorkerSettings.on_startup is startup
        assert WorkerSettings.on_shutdown is shutdown
        assert callable(WorkerSettings.on_startup)
        assert callable(WorkerSettings.on_shutdown)

    def test_redis_settings_from_dsn(self):
        assert WorkerSettings.redis_settings is not None
