from __future__ import annotations

import pytest
from fastapi import HTTPException

from uuid import UUID

from core.auth.models import CurrentUser
from core.db.base_service import BaseService


def test_require_current_user_raises_when_missing() -> None:
    service = BaseService(current_user=None)

    with pytest.raises(HTTPException) as exc_info:
        service.require_current_user()

    assert exc_info.value.status_code == 401


def test_require_current_user_returns_user() -> None:
    user = CurrentUser(id=UUID("00000000-0000-0000-0000-000000000001"))
    service = BaseService(current_user=user)

    result = service.require_current_user()

    assert result.id == user.id
