Jul 10 - Add test suite
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
from datetime import timedelta
|
||||
from dotenv import load_dotenv
|
||||
from sqlalchemy.pool import StaticPool
|
||||
|
||||
# Load .env from the project root (only takes effect locally; no-op in production
|
||||
# if variables are already set in the environment)
|
||||
@@ -80,8 +81,34 @@ class ProductionConfig(Config):
|
||||
# Inherits SESSION_COOKIE_SECURE = True from Config — no override needed.
|
||||
|
||||
|
||||
class TestingConfig(Config):
|
||||
"""Config for the automated test suite (pytest).
|
||||
|
||||
Uses an in-memory SQLite database with a StaticPool so the single
|
||||
connection — and therefore the schema created by db.create_all() — persists
|
||||
across every request the test client makes within one app instance. CSRF and
|
||||
rate limiting are disabled so tests can POST directly, and mail is
|
||||
suppressed. DEBUG=True short-circuits the file-logging block in create_app()
|
||||
so the suite never writes to logs/jqc.log.
|
||||
"""
|
||||
TESTING = True
|
||||
DEBUG = True
|
||||
|
||||
SQLALCHEMY_DATABASE_URI = 'sqlite://' # in-memory
|
||||
SQLALCHEMY_ENGINE_OPTIONS = {
|
||||
'connect_args': {'check_same_thread': False},
|
||||
'poolclass': StaticPool,
|
||||
}
|
||||
|
||||
WTF_CSRF_ENABLED = False
|
||||
RATELIMIT_ENABLED = False
|
||||
MAIL_SUPPRESS_SEND = True
|
||||
SESSION_COOKIE_SECURE = False
|
||||
|
||||
|
||||
config = {
|
||||
'development': DevelopmentConfig,
|
||||
'production': ProductionConfig,
|
||||
'testing': TestingConfig,
|
||||
'default': DevelopmentConfig,
|
||||
}
|
||||
Reference in New Issue
Block a user