@@ -531,6 +531,48 @@ def test_get_hit_w_ping_expired(self):
531
531
self .assertTrue (SESSIONS [0 ]._exists_checked )
532
532
self .assertFalse (pool ._sessions .full ())
533
533
534
+ def test_get_hit_w_created (self ):
535
+ import datetime
536
+
537
+ pool = self ._make_one (size = 4 )
538
+ database = _Database ("name" )
539
+ SESSIONS = [_Session (database )] * 4
540
+ database ._sessions .extend (SESSIONS )
541
+ pool .bind (database )
542
+
543
+ session_max_age = 28 * 24 * 60 * 60
544
+ SESSIONS [0 ]._created_at = datetime .datetime .utcnow () - datetime .timedelta (
545
+ seconds = session_max_age + 10
546
+ )
547
+
548
+ session = pool .get ()
549
+
550
+ self .assertIs (session , SESSIONS [0 ])
551
+ self .assertTrue (session ._exists_checked )
552
+ self .assertFalse (pool ._sessions .full ())
553
+
554
+ def test_get_hit_w_created_expired (self ):
555
+ import datetime
556
+
557
+ pool = self ._make_one (size = 4 )
558
+ database = _Database ("name" )
559
+ SESSIONS = [_Session (database )] * 5
560
+ database ._sessions .extend (SESSIONS )
561
+ pool .bind (database )
562
+
563
+ session_max_age = 28 * 24 * 60 * 60
564
+ SESSIONS [0 ]._created_at = datetime .datetime .utcnow () - datetime .timedelta (
565
+ seconds = session_max_age
566
+ )
567
+ SESSIONS [0 ]._exists = False
568
+
569
+ session = pool .get ()
570
+
571
+ self .assertIs (session , SESSIONS [4 ])
572
+ session .create .assert_called ()
573
+ self .assertTrue (SESSIONS [0 ]._exists_checked )
574
+ self .assertFalse (pool ._sessions .full ())
575
+
534
576
def test_get_empty_default_timeout (self ):
535
577
import queue
536
578
0 commit comments