Initial commit: Clean Mold Cost Calculator application
- Flask-based mold cost calculation application - PostgreSQL database with SQLAlchemy ORM - Docker/Podman containerization - Comprehensive documentation in docs/ - Clean, organized codebase without obsolete files - Production-ready deployment configuration - Enhanced pytest configuration with coverage reporting - Master/Development branch structure
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import os
|
||||
import pytest
|
||||
from app import create_app, db
|
||||
from app.config import Config
|
||||
|
||||
class TestConfig(Config):
|
||||
"""Test configuration that overrides the base configuration."""
|
||||
TESTING = True
|
||||
DEBUG = True
|
||||
SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'
|
||||
WTF_CSRF_ENABLED = False
|
||||
LOG_LEVEL = 'DEBUG'
|
||||
|
||||
# Override required settings for testing
|
||||
SECRET_KEY = 'testing-secret-key-not-used-in-production'
|
||||
MAIL_SUPPRESS_SEND = True
|
||||
RATELIMIT_ENABLED = False
|
||||
|
||||
# Testing-specific settings
|
||||
RATELIMIT_DEFAULT = "1000 per day;100 per hour;20 per minute"
|
||||
CACHE_TYPE = "SimpleCache"
|
||||
|
||||
def get_test_config():
|
||||
"""Get test configuration."""
|
||||
return TestConfig()
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def app():
|
||||
"""Create and configure a Flask app for testing."""
|
||||
app = create_app('testing')
|
||||
app.config.update(get_test_config())
|
||||
|
||||
# Create the database and load test data
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
yield app
|
||||
db.session.remove()
|
||||
db.drop_all()
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def client(app):
|
||||
"""A test client for the app."""
|
||||
return app.test_client()
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def runner(app):
|
||||
"""A test CLI runner for the app."""
|
||||
return app.test_cli_runner()
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def test_db(app):
|
||||
"""Create a fresh database for each test."""
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
yield db
|
||||
db.session.remove()
|
||||
db.drop_all()
|
||||
Reference in New Issue
Block a user