File size: 2,236 Bytes
5cf374f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import unittest
from unittest.mock import patch, MagicMock
import sys
import os

# Add the src directory to the path
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src'))

class TestChatbotIntegration(unittest.TestCase):
    
    @patch('app.initialize_rag')
    def test_rag_initialization(self, mock_initialize_rag):
        """Test that the RAG pipeline initializes correctly"""
        # Mock the RAG initialization
        mock_qa = MagicMock()
        mock_initialize_rag.return_value = mock_qa
        
        # Import app after mocking
        from app import qa_chain
        
        # Assert that initialize_rag was called
        mock_initialize_rag.assert_called_once()
        
        # Assert that qa_chain is set to the return value of initialize_rag
        self.assertEqual(qa_chain, mock_qa)
    
    def test_research_methods_info_exists(self):
        """Test that the research methods info file exists"""
        info_path = os.path.join(os.path.dirname(__file__), '..', 'research_methods_info.md')
        self.assertTrue(os.path.exists(info_path), "Research methods info file should exist")
        
        with open(info_path, 'r') as f:
            content = f.read()
        
        # Check for essential content
        self.assertIn('Qualitative Research Methods', content)
        self.assertIn('Quantitative Research Methods', content)
        self.assertIn('Mixed Methods Research', content)
        self.assertIn('APA7', content)
    
    def test_static_files_serving(self):
        """Test that the static files are properly configured"""
        from main import app
        
        # Check that the static files are mounted
        static_routes = [route for route in app.routes if getattr(route, 'path', '') == '/']
        self.assertTrue(len(static_routes) > 0, "Static files should be mounted")
    
    def test_api_mounting(self):
        """Test that the API is properly mounted"""
        from main import app
        
        # Check that the API is mounted
        api_routes = [route for route in app.routes if getattr(route, 'path', '') == '/api']
        self.assertTrue(len(api_routes) > 0, "API should be mounted")

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