Skip to content

Commit 90e0479

Browse files
committed
Adding back default state type as per unit test
1 parent 073ba2b commit 90e0479

2 files changed

Lines changed: 2 additions & 9 deletions

File tree

bluesky_httpserver/database/orm.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ class Session(Timestamped, Base):
183183
expiration_time = Column(DateTime(timezone=False), nullable=False)
184184
principal_id = Column(Integer, ForeignKey("principals.id"), nullable=False)
185185
revoked = Column(Boolean, default=False, nullable=False)
186-
# State allows for custom authenticator information to be stored in the session.
187-
state = Column(JSONVariant, nullable=False)
186+
state = Column(JSONVariant, default=dict, nullable=False)
188187
principal: Mapped[Principal] = relationship(back_populates="sessions", lazy="joined")
189188

190189

bluesky_httpserver/tests/test_database.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,7 @@ def test_session_state_defaults_to_empty_dict(sqlite_session):
6262
db.refresh(session)
6363
# Server default is '{}' so a session created without an explicit state
6464
# must not present as None to the ORM.
65-
assert reloaded_state(session) == {}
66-
67-
68-
def reloaded_state(session):
69-
# SQLite may return None if the server_default has not been re-selected;
70-
# normalize.
71-
return session.state if session.state is not None else {}
65+
assert session.state == {}
7266

7367

7468
def test_get_or_create_principal_creates_when_missing(sqlite_session):

0 commit comments

Comments
 (0)