Skip to content

Commit 2d074ba

Browse files
committed
Add comments and update the span event from a test
1 parent 8ddc07f commit 2d074ba

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/unit/test_pool.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ def test_get_non_expired(self):
214214
self.assertFalse(pool._sessions.full())
215215

216216
def test_spans_bind_get(self):
217+
# This tests retrieving 1 out of 4 sessions from the session pool.
217218
pool = self._make_one(size=4)
218219
database = _Database("name")
219220
SESSIONS = sorted([_Session(database) for i in range(0, 4)])
@@ -243,6 +244,7 @@ def test_spans_bind_get(self):
243244
self.assertSpanEvents("pool.Get", wantEventNames)
244245

245246
def test_spans_bind_get_empty_pool(self):
247+
# Tests trying to invoke pool.get() from an empty pool.
246248
pool = self._make_one(size=0)
247249
database = _Database("name")
248250
session1 = _Session(database)
@@ -270,6 +272,8 @@ def test_spans_bind_get_empty_pool(self):
270272
)
271273

272274
def test_spans_pool_bind(self):
275+
# Tests the exception generated from invoking pool.bind when
276+
# you have an empty pool.
273277
pool = self._make_one(size=1)
274278
database = _Database("name")
275279
SESSIONS = []
@@ -458,7 +462,7 @@ def test_spans_get_empty_pool(self):
458462
wantEventNames = [
459463
"Acquiring session",
460464
"Waiting for a session to become available",
461-
"No sessions available. Creating session",
465+
"No sessions available in pool. Creating session",
462466
]
463467
self.assertSpanEvents("pool.Get", wantEventNames)
464468

@@ -477,6 +481,8 @@ def test_get_non_empty_session_exists(self):
477481
self.assertTrue(pool._sessions.empty())
478482

479483
def test_spans_get_non_empty_session_exists(self):
484+
# Tests the spans produces when you invoke pool.bind
485+
# and then insert a session into the pool.
480486
pool = self._make_one()
481487
database = _Database("name")
482488
previous = _Session(database)
@@ -526,6 +532,7 @@ def test_put_empty(self):
526532
self.assertFalse(pool._sessions.empty())
527533

528534
def test_spans_put_empty(self):
535+
# Tests the spans produced when you put sessions into an empty pool.
529536
pool = self._make_one()
530537
database = _Database("name")
531538
pool.bind(database)
@@ -555,6 +562,8 @@ def test_put_full(self):
555562
self.assertIs(pool.get(), older)
556563

557564
def test_spans_put_full(self):
565+
# This scenario tests the spans produced from putting an older
566+
# session into a pool that is already full.
558567
pool = self._make_one(target_size=1)
559568
database = _Database("name")
560569
pool.bind(database)
@@ -867,7 +876,9 @@ def test_ping_oldest_stale_and_not_exists(self):
867876
SESSIONS[1].create.assert_called()
868877
self.assertNoSpans()
869878

870-
def test_spans_get_empty_pool(self):
879+
def test_spans_get_and_leave_empty_pool(self):
880+
# This scenario tests the spans generated from pulling a span
881+
# out the pool and leaving it empty.
871882
pool = self._make_one()
872883
database = _Database("name")
873884
session1 = _Session(database)

0 commit comments

Comments
 (0)