mirror of
https://github.com/vee1e/bulk-questionnaire-upload.git
synced 2026-09-01 09:50:06 +00:00
feat: implement CI workflow, enhance file validation, and add test cases
- Introduced a CI workflow for automated testing of backend and frontend components. - Added pytest configuration for backend tests and Vitest configuration for frontend tests. - Enhanced file validation logic in the backend to improve error handling and reporting. - Created comprehensive test cases for various validation scenarios, including edge cases and incorrect formats. - Updated requirements to include necessary testing libraries and tools.
This commit is contained in:
parent
edaff71fe3
commit
165b249c3d
49 changed files with 2187 additions and 90 deletions
46
tests/backend/conftest.py
Normal file
46
tests/backend/conftest.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import os
|
||||
import sys
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
import httpx
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', 'backend'))
|
||||
import main
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def client():
|
||||
transport = httpx.ASGITransport(app=main.app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as c:
|
||||
yield c
|
||||
|
||||
|
||||
@pytest_asyncio.fixture(autouse=True)
|
||||
async def mock_db_services(monkeypatch):
|
||||
"""Mock database services to avoid requiring MongoDB"""
|
||||
|
||||
# Mock database connection functions
|
||||
async def mock_connect_to_mongo():
|
||||
pass
|
||||
|
||||
async def mock_close_mongo_connection():
|
||||
pass
|
||||
|
||||
monkeypatch.setattr(main, 'connect_to_mongo', mock_connect_to_mongo)
|
||||
monkeypatch.setattr(main, 'close_mongo_connection', mock_close_mongo_connection)
|
||||
|
||||
# Mock database service
|
||||
class MockDatabaseService:
|
||||
async def get_all_forms(self):
|
||||
return []
|
||||
|
||||
async def get_form_by_id(self, form_id: str):
|
||||
return None # Simulate form not found
|
||||
|
||||
async def get_questions_by_form_id(self, form_id: str):
|
||||
return []
|
||||
|
||||
async def get_options_by_form_id(self, form_id: str):
|
||||
return []
|
||||
|
||||
monkeypatch.setattr(main, 'db_service', MockDatabaseService())
|
||||
Loading…
Add table
Add a link
Reference in a new issue