File size: 1,971 Bytes
674fb4e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | """
Basic tests for core components
"""
import pytest
from src.graph_rag_service.core.models import Entity, Relationship, Chunk
def test_entity_creation():
"""Test creating an entity"""
entity = Entity(
name="Acme Corp",
type="Company",
properties={"industry": "Technology", "founded": "2020"}
)
assert entity.name == "Acme Corp"
assert entity.type == "Company"
assert entity.properties["industry"] == "Technology"
assert entity.confidence == 1.0
def test_relationship_creation():
"""Test creating a relationship"""
rel = Relationship(
source="Acme Corp",
target="Partner Inc",
type="PARTNERS_WITH",
confidence=0.9
)
assert rel.source == "Acme Corp"
assert rel.target == "Partner Inc"
assert rel.type == "PARTNERS_WITH"
assert rel.confidence == 0.9
def test_chunk_creation():
"""Test creating a chunk"""
chunk = Chunk(
text="Sample text content",
document_id="doc123",
chunk_index=0
)
assert chunk.text == "Sample text content"
assert chunk.document_id == "doc123"
assert chunk.chunk_index == 0
@pytest.mark.asyncio
async def test_llm_factory():
"""Test LLM factory creation"""
from src.graph_rag_service.core.llm_factory import LLMFactory
# Test creating with default provider
provider = LLMFactory.create()
assert provider is not None
assert provider.provider_name in ["ollama", "openai", "anthropic", "gemini"]
def test_config_loading():
"""Test configuration loading"""
from src.graph_rag_service.config import settings
assert settings.app_name == "Graph RAG Service"
assert settings.app_version == "0.1.0"
assert settings.default_llm_provider in ["ollama", "openai", "anthropic", "gemini"]
assert settings.chunk_size > 0
assert settings.default_top_k > 0
if __name__ == "__main__":
pytest.main([__file__, "-v"])
|