"""
Tests for Flywheel Module - RAG Pipeline.
Tests document ingestion and processing.
"""
import pytest
import tempfile
import os
from pathlib import Path
from unittest.mock import Mock, patch, AsyncMock
from src.flywheel.rag_pipeline import (
RAGIngestionPipeline,
DocumentMetadata,
DocumentChunk,
IngestionResult,
get_rag_pipeline
)
class TestDocumentMetadata:
"""Tests for DocumentMetadata dataclass."""
def test_default_values(self):
"""Test default metadata values."""
meta = DocumentMetadata(
filename="test.md",
filepath="/path/test.md",
technology="linux",
tenant_id="tenant-001",
doc_type="manual"
)
assert meta.language == "pt"
assert meta.version == "1.0"
assert meta.tags == []
class TestRAGPipeline:
"""Tests for RAGIngestionPipeline."""
@pytest.fixture
def pipeline(self):
"""Create pipeline with mocked Qdrant and Ollama."""
with patch('src.flywheel.rag_pipeline.get_qdrant_client') as mock_qdrant, \
patch('src.flywheel.rag_pipeline.get_ollama_client') as mock_ollama:
mock_qdrant.return_value = Mock()
mock_qdrant.return_value.upsert_document = Mock(return_value=True)
# Mock Ollama client for embeddings
mock_ollama.return_value = Mock()
mock_ollama.return_value.get_embeddings = AsyncMock(return_value=[0.1] * 384)
return RAGIngestionPipeline()
def test_sanitize_removes_scripts(self, pipeline):
"""Test that script tags are removed."""
content = "Normal text more text"
result = pipeline._sanitize_content(content)
assert "