mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Fix User.current_galaxy_session
This commit is contained in:
@@ -10761,7 +10761,9 @@ User.preferences = association_proxy("_preferences", "value", creator=UserPrefer
|
||||
# See https://github.com/sqlalchemy/sqlalchemy/discussions/7638 for approach
|
||||
session_partition = select(
|
||||
GalaxySession,
|
||||
func.row_number().over(order_by=GalaxySession.update_time, partition_by=GalaxySession.user_id).label("index"),
|
||||
func.row_number()
|
||||
.over(order_by=GalaxySession.update_time.desc(), partition_by=GalaxySession.user_id)
|
||||
.label("index"),
|
||||
).alias()
|
||||
partitioned_session = aliased(GalaxySession, session_partition)
|
||||
User.current_galaxy_session = relationship(
|
||||
|
||||
@@ -698,6 +698,17 @@ class TestMappings(BaseModelTestCase):
|
||||
session.add(lf)
|
||||
session.flush()
|
||||
|
||||
def test_current_session(self):
|
||||
user = model.User(email="testworkflows@bx.psu.edu", password="password")
|
||||
galaxy_session = model.GalaxySession()
|
||||
galaxy_session.user = user
|
||||
self.persist(user, galaxy_session)
|
||||
assert user.current_galaxy_session == galaxy_session
|
||||
new_galaxy_session = model.GalaxySession()
|
||||
new_galaxy_session.user = user
|
||||
self.persist(user, new_galaxy_session)
|
||||
assert user.current_galaxy_session == new_galaxy_session
|
||||
|
||||
def test_flush_refreshes(self):
|
||||
# Normally I don't believe in unit testing library code, but the behaviors around attribute
|
||||
# states and flushing in SQL Alchemy is very subtle and it is good to have a executable
|
||||
|
||||
Reference in New Issue
Block a user