"""
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
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."""
with patch('src.flywheel.rag_pipeline.get_qdrant_client') as mock:
mock.return_value = Mock()
mock.return_value.upsert_document = Mock(return_value=True)
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 "