refactor: split monolithic app.py into modular Flask application with factory pattern
- Created app/ package with 6 modules: - __init__.py: Application factory (create_app function) - routes.py: All route handlers (473 lines) - models.py: Data persistence layer (41 lines) - validators.py: Input validation functions (48 lines) - email_service.py: Email sending functions (85 lines) - utils.py: Utility functions (30 lines) - Implemented Flask application factory pattern - Created run.py as minimal entry point - Updated all test imports to use new module structure - Fixed template/static folder paths for package structure - All 102 tests passing - Improved maintainability with clear separation of concerns - Follows Flask best practices for scalable applications
This commit is contained in:
@@ -3,7 +3,7 @@ Integration tests for the complete application workflow.
|
||||
"""
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
from app import load_application_data
|
||||
from app.models import load_application_data
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
@@ -13,7 +13,7 @@ class TestCompleteWorkflow:
|
||||
def test_complete_application_workflow(self, client, app, sample_pdf_file):
|
||||
"""Test the complete workflow from email to confirmation."""
|
||||
# Step 1: Submit email
|
||||
with patch('app.mail.send'):
|
||||
with patch('app.email_service.mail.send'):
|
||||
response = client.post('/apply/submit-email', data={
|
||||
'email': 'integration@test.com',
|
||||
'job_name': 'Integration Test Position'
|
||||
@@ -22,7 +22,7 @@ class TestCompleteWorkflow:
|
||||
assert response.status_code == 200
|
||||
|
||||
# For testing, create a known session
|
||||
from app import save_application_data
|
||||
from app.models import save_application_data
|
||||
session_id = 'integration-test-123'
|
||||
save_application_data(session_id, {
|
||||
'session_id': session_id,
|
||||
@@ -130,7 +130,7 @@ class TestCompleteWorkflow:
|
||||
|
||||
def test_multiple_concurrent_applications(self, client, app):
|
||||
"""Test handling multiple concurrent applications with different sessions."""
|
||||
from app import save_application_data
|
||||
from app.models import save_application_data
|
||||
|
||||
# Create multiple applications
|
||||
sessions = []
|
||||
@@ -182,7 +182,7 @@ class TestWorkflowEdgeCases:
|
||||
|
||||
def test_skip_optional_fields(self, client, app):
|
||||
"""Test completing workflow without filling optional fields."""
|
||||
from app import save_application_data
|
||||
from app.models import save_application_data
|
||||
|
||||
session_id = 'optional-test'
|
||||
save_application_data(session_id, {
|
||||
@@ -226,7 +226,7 @@ class TestWorkflowEdgeCases:
|
||||
|
||||
def test_workflow_with_unicode_data(self, client, app):
|
||||
"""Test workflow with German special characters."""
|
||||
from app import save_application_data
|
||||
from app.models import save_application_data
|
||||
|
||||
session_id = 'unicode-test'
|
||||
save_application_data(session_id, {
|
||||
@@ -265,7 +265,7 @@ class TestDataIntegrity:
|
||||
|
||||
def test_data_not_lost_between_pages(self, client, app):
|
||||
"""Test that data persists correctly when navigating between pages."""
|
||||
from app import save_application_data
|
||||
from app.models import save_application_data
|
||||
|
||||
session_id = 'persistence-test'
|
||||
save_application_data(session_id, {
|
||||
|
||||
Reference in New Issue
Block a user