"""Tests for BaseStorage.generate_id concrete method."""

import uuid
from typing import Any, Dict, List, Optional

from local_deep_research.news.core.storage import BaseStorage


class ConcreteStorage(BaseStorage):
    """Minimal concrete subclass for testing the base generate_id method."""

    def create(self, data: Dict[str, Any]) -> str:
        return ""

    def get(self, id: str) -> Optional[Dict[str, Any]]:
        return None

    def update(self, id: str, data: Dict[str, Any]) -> bool:
        return False

    def delete(self, id: str) -> bool:
        return False

    def list(
        self,
        filters: Optional[Dict[str, Any]] = None,
        limit: int = 100,
        offset: int = 0,
    ) -> List[Dict[str, Any]]:
        return []


class TestBaseStorageGenerateId:
    def test_returns_valid_uuid_string(self):
        storage = ConcreteStorage()
        result = storage.generate_id()
        # Should be a valid UUID4 string
        parsed = uuid.UUID(result, version=4)
        assert str(parsed) == result

    def test_returns_unique_ids(self):
        storage = ConcreteStorage()
        ids = {storage.generate_id() for _ in range(100)}
        assert len(ids) == 100

    def test_returns_string_type(self):
        storage = ConcreteStorage()
        result = storage.generate_id()
        assert isinstance(result, str)
