"""Tests for research_scheduler routes."""

from unittest.mock import patch


from local_deep_research.research_scheduler.routes import (
    get_current_username,
    scheduler_bp,
)


class TestGetCurrentUsername:
    """Tests for get_current_username function."""

    def test_returns_username_from_session(self):
        """Should return username from session."""
        with patch(
            "local_deep_research.research_scheduler.routes.session",
            {"username": "testuser"},
        ):
            result = get_current_username()
        assert result == "testuser"

    def test_returns_none_when_no_username(self):
        """Should return None when no username in session."""
        with patch("local_deep_research.research_scheduler.routes.session", {}):
            result = get_current_username()
        assert result is None


class TestSchedulerBlueprint:
    """Tests for scheduler blueprint configuration."""

    def test_blueprint_name(self):
        """Should have correct blueprint name."""
        assert scheduler_bp.name == "document_scheduler"

    def test_blueprint_exists(self):
        """Should have valid blueprint."""
        assert scheduler_bp is not None
