File size: 1,901 Bytes
f866820
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Integration tests for the RAG Document Assistant
"""

import unittest
import os

class TestRAGIntegration(unittest.TestCase):
    
    def setUp(self):
        """Set up test environment before each test method."""
        # Add the parent directory to the path
        parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
        if parent_dir not in sys.path:
            sys.path.insert(0, parent_dir)
    
    def test_embedding_generation(self):
        """Test embedding generation functionality"""
        try:
            from src.ingestion.embeddings import get_embedding
            
            # Test with a simple text
            text = "This is a test sentence for embedding."
            embedding = get_embedding(text)
            
            # Check that we got a list of floats
            self.assertIsInstance(embedding, list)
            self.assertGreater(len(embedding), 0)
            self.assertIsInstance(embedding[0], float)
            
        except ImportError:
            # Skip if dependencies are not available
            self.skipTest("Embedding dependencies not available")
    
    def test_chunking_functionality(self):
        """Test text chunking functionality"""
        try:
            from src.ingestion.chunker import chunk_text
            
            # Test with a longer text
            text = "This is the first sentence. " * 200  # Create a long text
            chunks = chunk_text(text, chunk_size=100, overlap=10)
            
            # Check that we got chunks
            self.assertIsInstance(chunks, list)
            self.assertGreater(len(chunks), 0)
            self.assertIsInstance(chunks[0], str)
            
        except ImportError:
            # Skip if dependencies are not available
            self.skipTest("Chunking dependencies not available")

if __name__ == '__main__':
    unittest.main()