|
|
import unittest |
|
|
from unittest.mock import patch, MagicMock |
|
|
import sys |
|
|
import os |
|
|
|
|
|
|
|
|
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_qa = MagicMock() |
|
|
mock_initialize_rag.return_value = mock_qa |
|
|
|
|
|
|
|
|
from app import qa_chain |
|
|
|
|
|
|
|
|
mock_initialize_rag.assert_called_once() |
|
|
|
|
|
|
|
|
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() |
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
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() |
|
|
|