84 lines
2.4 KiB
Python
84 lines
2.4 KiB
Python
"""Shared test fixtures for the ingestion test suite."""
|
|
|
|
import pytest
|
|
from pathlib import Path
|
|
from unittest.mock import MagicMock
|
|
|
|
from ingestion.config import IngestionConfig
|
|
from ingestion.enrichment.models import ActionItem, EnrichmentResult, Entity
|
|
|
|
|
|
@pytest.fixture
|
|
def tmp_notes_dir(tmp_path: Path) -> Path:
|
|
"""Create a temporary notes directory structure."""
|
|
notes = tmp_path / "notes"
|
|
notes.mkdir()
|
|
(notes / "inbox").mkdir()
|
|
(notes / "meetings").mkdir()
|
|
(notes / "projects").mkdir()
|
|
(notes / "people").mkdir()
|
|
(notes / "decisions").mkdir()
|
|
return notes
|
|
|
|
|
|
@pytest.fixture
|
|
def tmp_inbox(tmp_path: Path) -> Path:
|
|
"""Create a temporary inbox directory."""
|
|
inbox = tmp_path / "inbox"
|
|
inbox.mkdir()
|
|
return inbox
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_config(tmp_path: Path) -> IngestionConfig:
|
|
"""Create a test configuration with temporary paths."""
|
|
notes_dir = tmp_path / "notes"
|
|
notes_dir.mkdir(exist_ok=True)
|
|
inbox_dir = tmp_path / "inbox"
|
|
inbox_dir.mkdir(exist_ok=True)
|
|
return IngestionConfig(
|
|
llm_provider="openai",
|
|
llm_model="gpt-4o",
|
|
openai_api_key="test-key-fake",
|
|
notes_dir=str(notes_dir),
|
|
inbox_dir=str(inbox_dir),
|
|
auto_commit=False,
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_enrichment_result() -> EnrichmentResult:
|
|
"""Create a sample enrichment result for testing."""
|
|
return EnrichmentResult(
|
|
title="Meeting with Beier GmbH",
|
|
category="meeting",
|
|
tags=["meeting", "customer"],
|
|
entities=[
|
|
Entity(type="person", value="Thomas Beier", confidence=0.95),
|
|
Entity(type="project", value="Druckluft", confidence=0.9),
|
|
Entity(type="date", value="2024-03-15", confidence=0.99),
|
|
],
|
|
action_items=[
|
|
ActionItem(description="Send updated proposal", assignee="André", deadline="2024-03-22"),
|
|
ActionItem(description="Schedule follow-up meeting"),
|
|
],
|
|
summary="Discussion about the Druckluft project.",
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_llm_client():
|
|
"""Create a mock LLM client that returns a valid enrichment JSON."""
|
|
import json
|
|
|
|
mock = MagicMock()
|
|
mock.complete.return_value = json.dumps({
|
|
"title": "Test Note",
|
|
"category": "inbox",
|
|
"tags": ["test"],
|
|
"entities": [],
|
|
"action_items": [],
|
|
"summary": "A test note.",
|
|
})
|
|
return mock
|