Skip to content

Commit 8b54a5f

Browse files
committed
Update docs and add test for new config key SESSION_SQLALCHEMY_CREATE_TABLE
1 parent ae4f137 commit 8b54a5f

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

docs/config_reference.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ SqlAlchemy
174174

175175
Default: ``'sessions'``
176176

177+
.. py:data:: SESSION_SQLALCHEMY_CREATE_TABLE
178+
179+
Whether (or not) Flask-Session should manage creation of the table for storing session data.
180+
181+
Default: ``True``
182+
177183
.. py:data:: SESSION_SQLALCHEMY_SEQUENCE
178184
179185
The name of the sequence you want to use for the primary key.

tests/test_sqlalchemy.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,22 @@ def test_use_signer(self, app_utils):
5757
json.loads(byte_string.decode("utf-8")) if byte_string else {}
5858
)
5959
assert stored_session.get("value") == "44"
60+
61+
@pytest.mark.filterwarnings("ignore:No valid SQLAlchemy instance provided")
62+
def test_database_not_created_automatically(self, app_utils):
63+
app = app_utils.create_app(
64+
{
65+
"SESSION_TYPE": "sqlalchemy",
66+
"SQLALCHEMY_DATABASE_URI": "sqlite:///",
67+
"SESSION_SQLALCHEMY_CREATE_TABLE": False,
68+
}
69+
)
70+
with app.app_context() and self.setup_sqlalchemy(
71+
app
72+
) and app.test_request_context():
73+
assert isinstance(
74+
flask.session,
75+
SqlAlchemySession,
76+
)
77+
with pytest.raises(AssertionError):
78+
app_utils.test_session(app)

0 commit comments

Comments
 (0)