import pytest
from pathlib import Path
from datetime import date
from chitai.services.metadata_extractor import EpubExtractor


@pytest.mark.asyncio()
class TestEpubExtractor:
    async def test_extraction_by_path(self):
        path = Path("tests/data_files/Moby Dick; Or, The Whale - Herman Melville.epub")

        metadata = await EpubExtractor.extract_metadata(path)

        assert metadata["title"] == "Moby Dick; Or, The Whale"
        assert metadata["authors"] == ["Herman Melville"]
        assert metadata["published_date"] == date(year=2001, month=7, day=1)

