"""Shared pytest fixtures using only local fakes and temporary directories."""

from __future__ import annotations

from pathlib import Path

import pytest
import pytest_asyncio

from app.database.database import Database
from app.database.repository import Repository
from tests.helpers import MP4_HEADER, build_settings


@pytest.fixture
def settings(tmp_path: Path):
    result = build_settings(tmp_path)
    result.ensure_directories()
    return result


@pytest.fixture
def mp4_header() -> bytes:
    return MP4_HEADER


@pytest_asyncio.fixture
async def repository(tmp_path: Path) -> Repository:
    database = Database(tmp_path / "test.db")
    await database.connect()
    repo = Repository(database)
    try:
        yield repo
    finally:
        await database.close()
