@@ -50,12 +50,16 @@ async def test_save_retrieve_fifo_cleanup_lifecycle(self):
5050 # Records should be in reverse chronological order (newest first)
5151 sources = [r .source for r in records ]
5252 expected_sources = ["tool_2" , "tool_1" , "tool_0" ] # Newest first
53- assert sources == expected_sources , f"Expected { expected_sources } , got { sources } "
53+ assert sources == expected_sources , (
54+ f"Expected { expected_sources } , got { sources } "
55+ )
5456
5557 # Verify timestamps are in descending order
5658 timestamps = [r .timestamp for r in records ]
5759 for i in range (len (timestamps ) - 1 ):
58- assert timestamps [i ] >= timestamps [i + 1 ], "Records should be ordered newest first"
60+ assert timestamps [i ] >= timestamps [i + 1 ], (
61+ "Records should be ordered newest first"
62+ )
5963
6064 print (f"✅ Phase 2: Records retrieved in correct order: { sources } " )
6165
@@ -74,12 +78,16 @@ async def test_save_retrieve_fifo_cleanup_lifecycle(self):
7478
7579 # Verify FIFO cleanup worked
7680 records = await db .get_session_conversations (session_id )
77- assert len (records ) == 3 , f"Expected 3 records after cleanup, got { len (records )} "
81+ assert len (records ) == 3 , (
82+ f"Expected 3 records after cleanup, got { len (records )} "
83+ )
7884
7985 # Should have the 3 most recent records
8086 sources = [r .source for r in records ]
8187 expected_sources = ["tool_4" , "tool_3" , "tool_2" ] # Most recent 3
82- assert sources == expected_sources , f"Expected { expected_sources } , got { sources } "
88+ assert sources == expected_sources , (
89+ f"Expected { expected_sources } , got { sources } "
90+ )
8391
8492 print (f"✅ Phase 3: FIFO cleanup worked correctly: { sources } " )
8593
@@ -186,7 +194,9 @@ async def test_time_based_cleanup_integration(self):
186194 # Records should still exist (within retention period)
187195 records_after = await db .get_session_conversations ("time_test_session" )
188196 assert len (records_after ) == 4
189- print (f"✅ After time-based cleanup: { len (records_after )} records (within retention)" )
197+ print (
198+ f"✅ After time-based cleanup: { len (records_after )} records (within retention)"
199+ )
190200
191201 @pytest .mark .asyncio
192202 async def test_lru_session_cleanup_lifecycle (self ):
@@ -247,7 +257,9 @@ async def test_lru_session_cleanup_lifecycle(self):
247257 # Should be sessions B and C (oldest last activity)
248258 assert "session_B" in lru_sessions , "Session B should be LRU"
249259 assert "session_C" in lru_sessions , "Session C should be LRU"
250- assert "session_A" not in lru_sessions , "Session A should NOT be LRU (recent activity)"
260+ assert "session_A" not in lru_sessions , (
261+ "Session A should NOT be LRU (recent activity)"
262+ )
251263 print ("✅ Phase 2: LRU detection working correctly" )
252264
253265 # PHASE 3: Trigger LRU cleanup
@@ -269,7 +281,13 @@ async def test_lru_session_cleanup_lifecycle(self):
269281 # PHASE 4: Verify which sessions remain
270282 print ("\n 🔍 PHASE 4: Verifying remaining sessions..." )
271283
272- sessions_to_check = ["session_A" , "session_B" , "session_C" , "session_D" , "session_E" ]
284+ sessions_to_check = [
285+ "session_A" ,
286+ "session_B" ,
287+ "session_C" ,
288+ "session_D" ,
289+ "session_E" ,
290+ ]
273291 remaining_sessions = []
274292 deleted_sessions = []
275293
@@ -278,15 +296,23 @@ async def test_lru_session_cleanup_lifecycle(self):
278296 if records :
279297 remaining_sessions .append (session_id )
280298 last_activity = max (r .timestamp for r in records )
281- print (f" ✅ { session_id } : { len (records )} records, last activity: { last_activity } " )
299+ print (
300+ f" ✅ { session_id } : { len (records )} records, last activity: { last_activity } "
301+ )
282302 else :
283303 deleted_sessions .append (session_id )
284304 print (f" ❌ { session_id } : DELETED (was least recently used)" )
285305
286306 # Verify correct sessions were kept/deleted
287- assert "session_A" in remaining_sessions , "Session A should remain (most recent activity)"
288- assert "session_D" in remaining_sessions , "Session D should remain (recent creation)"
289- assert "session_E" in remaining_sessions , "Session E should remain (most recent creation)"
307+ assert "session_A" in remaining_sessions , (
308+ "Session A should remain (most recent activity)"
309+ )
310+ assert "session_D" in remaining_sessions , (
311+ "Session D should remain (recent creation)"
312+ )
313+ assert "session_E" in remaining_sessions , (
314+ "Session E should remain (most recent creation)"
315+ )
290316 assert "session_B" in deleted_sessions , "Session B should be deleted (LRU)"
291317 assert "session_C" in deleted_sessions , "Session C should be deleted (LRU)"
292318
@@ -296,7 +322,9 @@ async def test_lru_session_cleanup_lifecycle(self):
296322 print ("\n 📊 PHASE 5: Verifying session record preservation..." )
297323
298324 session_a_records = await db .get_session_conversations ("session_A" )
299- assert len (session_a_records ) == 2 , f"Session A should have 2 records, got { len (session_a_records )} "
325+ assert len (session_a_records ) == 2 , (
326+ f"Session A should have 2 records, got { len (session_a_records )} "
327+ )
300328
301329 # Check that both records exist
302330 sources = [r .source for r in session_a_records ]
0 commit comments