ERMA / test_integration.py
mfirat007's picture
Upload 27 files
5cf374f verified
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()