Require production database configuration

This commit is contained in:
SowinskiBraeden committed 2026-06-28 17:52:22 -07:00
1 parent adbc60bfc3
commit 593420f984
3 files changed
+43 -2

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
import os
import unittest
from unittest.mock import patch
from app import create_app
class ProductionConfigTests(unittest.TestCase):
def test_production_refuses_default_sqlite_database(self):
with patch.dict(
os.environ,
{"APP_ENV": "production"},
clear=False,
):
with self.assertRaisesRegex(RuntimeError, "DATABASE_URL"):
create_app({"SECRET_KEY": "test-production-secret"})
def test_production_accepts_postgresql_database_url(self):
with patch.dict(
os.environ,
{"APP_ENV": "production"},
clear=False,
):
app = create_app(
{
"SECRET_KEY": "test-production-secret",
"SQLALCHEMY_DATABASE_URI": "postgresql+psycopg://user:password@example.com/dbname",
}
)
self.assertTrue(app.config["SESSION_COOKIE_SECURE"])
self.assertEqual(app.config["SESSION_COOKIE_SAMESITE"], "Strict")
self.assertTrue(app.config["SQLALCHEMY_DATABASE_URI"].startswith("postgresql+psycopg://"))
if __name__ == "__main__":
unittest.main()