fix: Update CI tests for new unified examples interface
- Rename test_main_cli.py to test_document_rag.py - Update all references from main_cli_example.py to document_rag.py - Update tests/README.md documentation The tests now properly test the new unified interface while maintaining the same test coverage and functionality.
This commit is contained in:
@@ -18,8 +18,8 @@ Basic functionality tests that verify:
|
|||||||
- Basic index building and searching works for both HNSW and DiskANN backends
|
- Basic index building and searching works for both HNSW and DiskANN backends
|
||||||
- Uses parametrized tests to test both backends
|
- Uses parametrized tests to test both backends
|
||||||
|
|
||||||
### `test_main_cli.py`
|
### `test_document_rag.py`
|
||||||
Tests the main CLI example functionality:
|
Tests the document RAG example functionality (formerly main_cli_example):
|
||||||
- Tests with facebook/contriever embeddings
|
- Tests with facebook/contriever embeddings
|
||||||
- Tests with OpenAI embeddings (if API key is available)
|
- Tests with OpenAI embeddings (if API key is available)
|
||||||
- Tests error handling with invalid parameters
|
- Tests error handling with invalid parameters
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
Test main_cli_example functionality using pytest.
|
Test document_rag (formerly main_cli_example) functionality using pytest.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@@ -20,14 +20,14 @@ def test_data_dir():
|
|||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
os.environ.get("CI") == "true", reason="Skip model tests in CI to avoid MPS memory issues"
|
os.environ.get("CI") == "true", reason="Skip model tests in CI to avoid MPS memory issues"
|
||||||
)
|
)
|
||||||
def test_main_cli_simulated(test_data_dir):
|
def test_document_rag_simulated(test_data_dir):
|
||||||
"""Test main_cli with simulated LLM."""
|
"""Test document_rag with simulated LLM."""
|
||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
# Use a subdirectory that doesn't exist yet to force index creation
|
# Use a subdirectory that doesn't exist yet to force index creation
|
||||||
index_dir = Path(temp_dir) / "test_index"
|
index_dir = Path(temp_dir) / "test_index"
|
||||||
cmd = [
|
cmd = [
|
||||||
sys.executable,
|
sys.executable,
|
||||||
"examples/main_cli_example.py",
|
"examples/document_rag.py",
|
||||||
"--llm",
|
"--llm",
|
||||||
"simulated",
|
"simulated",
|
||||||
"--embedding-model",
|
"--embedding-model",
|
||||||
@@ -58,14 +58,14 @@ def test_main_cli_simulated(test_data_dir):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(not os.environ.get("OPENAI_API_KEY"), reason="OpenAI API key not available")
|
@pytest.mark.skipif(not os.environ.get("OPENAI_API_KEY"), reason="OpenAI API key not available")
|
||||||
def test_main_cli_openai(test_data_dir):
|
def test_document_rag_openai(test_data_dir):
|
||||||
"""Test main_cli with OpenAI embeddings."""
|
"""Test document_rag with OpenAI embeddings."""
|
||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
# Use a subdirectory that doesn't exist yet to force index creation
|
# Use a subdirectory that doesn't exist yet to force index creation
|
||||||
index_dir = Path(temp_dir) / "test_index_openai"
|
index_dir = Path(temp_dir) / "test_index_openai"
|
||||||
cmd = [
|
cmd = [
|
||||||
sys.executable,
|
sys.executable,
|
||||||
"examples/main_cli_example.py",
|
"examples/document_rag.py",
|
||||||
"--llm",
|
"--llm",
|
||||||
"simulated", # Use simulated LLM to avoid GPT-4 costs
|
"simulated", # Use simulated LLM to avoid GPT-4 costs
|
||||||
"--embedding-model",
|
"--embedding-model",
|
||||||
@@ -99,12 +99,12 @@ def test_main_cli_openai(test_data_dir):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_main_cli_error_handling(test_data_dir):
|
def test_document_rag_error_handling(test_data_dir):
|
||||||
"""Test main_cli with invalid parameters."""
|
"""Test document_rag with invalid parameters."""
|
||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
cmd = [
|
cmd = [
|
||||||
sys.executable,
|
sys.executable,
|
||||||
"examples/main_cli_example.py",
|
"examples/document_rag.py",
|
||||||
"--llm",
|
"--llm",
|
||||||
"invalid_llm_type",
|
"invalid_llm_type",
|
||||||
"--index-dir",
|
"--index-dir",
|
||||||
Reference in New Issue
Block a user