sebasmos's picture
Update demo with latest codebase changes
420bcec
raw
history blame
3.73 kB
"""Tests for RAG system."""
import pytest
from pathlib import Path
import tempfile
import shutil
from src.rag import ProjectRAG
class TestProjectRAG:
"""Tests for ProjectRAG class."""
def test_rag_initialization(self, temp_data_dir):
"""Test RAG system initializes correctly."""
with tempfile.TemporaryDirectory() as persist_dir:
rag = ProjectRAG(temp_data_dir, persist_dir=Path(persist_dir))
assert rag is not None
assert rag.data_dir == temp_data_dir
def test_load_and_index(self, temp_data_dir):
"""Test loading and indexing meetings."""
with tempfile.TemporaryDirectory() as persist_dir:
rag = ProjectRAG(temp_data_dir, persist_dir=Path(persist_dir))
rag.load_and_index()
assert len(rag.meetings) == 1
assert rag.meetings[0].project_name == "test_project"
def test_get_all_projects(self, temp_data_dir):
"""Test getting all project names."""
with tempfile.TemporaryDirectory() as persist_dir:
rag = ProjectRAG(temp_data_dir, persist_dir=Path(persist_dir))
rag.load_and_index()
projects = rag.get_all_projects()
assert "test_project" in projects
def test_get_open_action_items(self, temp_data_dir):
"""Test getting open action items."""
with tempfile.TemporaryDirectory() as persist_dir:
rag = ProjectRAG(temp_data_dir, persist_dir=Path(persist_dir))
rag.load_and_index()
items = rag.get_open_action_items()
# Should have 2 open items (Alice and Bob's tasks)
assert len(items) == 2
def test_get_open_action_items_filtered(self, temp_data_dir):
"""Test getting open action items filtered by project."""
with tempfile.TemporaryDirectory() as persist_dir:
rag = ProjectRAG(temp_data_dir, persist_dir=Path(persist_dir))
rag.load_and_index()
items = rag.get_open_action_items(project="test_project")
assert len(items) == 2
items = rag.get_open_action_items(project="nonexistent")
assert len(items) == 0
def test_get_blockers(self, temp_data_dir):
"""Test getting blockers."""
with tempfile.TemporaryDirectory() as persist_dir:
rag = ProjectRAG(temp_data_dir, persist_dir=Path(persist_dir))
rag.load_and_index()
blockers = rag.get_blockers()
assert len(blockers) == 2
def test_search(self, temp_data_dir):
"""Test semantic search."""
with tempfile.TemporaryDirectory() as persist_dir:
rag = ProjectRAG(temp_data_dir, persist_dir=Path(persist_dir))
rag.load_and_index()
results = rag.search("login page implementation")
assert len(results) > 0
def test_search_with_project_filter(self, temp_data_dir):
"""Test semantic search with project filter."""
with tempfile.TemporaryDirectory() as persist_dir:
rag = ProjectRAG(temp_data_dir, persist_dir=Path(persist_dir))
rag.load_and_index()
results = rag.search("login", project_filter="test_project")
assert len(results) > 0
results = rag.search("login", project_filter="nonexistent")
assert len(results) == 0
def test_get_recent_decisions(self, temp_data_dir):
"""Test getting recent decisions."""
with tempfile.TemporaryDirectory() as persist_dir:
rag = ProjectRAG(temp_data_dir, persist_dir=Path(persist_dir))
rag.load_and_index()
decisions = rag.get_recent_decisions()
assert len(decisions) == 2