Skip to content

Commit

Permalink
Add comments and update the span event from a test
Browse files Browse the repository at this point in the history
  • Loading branch information
odeke-em committed Dec 3, 2024
1 parent 8ddc07f commit 2d074ba
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/unit/test_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def test_get_non_expired(self):
self.assertFalse(pool._sessions.full())

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

def test_spans_bind_get_empty_pool(self):
# Tests trying to invoke pool.get() from an empty pool.
pool = self._make_one(size=0)
database = _Database("name")
session1 = _Session(database)
Expand Down Expand Up @@ -270,6 +272,8 @@ def test_spans_bind_get_empty_pool(self):
)

def test_spans_pool_bind(self):
# Tests the exception generated from invoking pool.bind when
# you have an empty pool.
pool = self._make_one(size=1)
database = _Database("name")
SESSIONS = []
Expand Down Expand Up @@ -458,7 +462,7 @@ def test_spans_get_empty_pool(self):
wantEventNames = [
"Acquiring session",
"Waiting for a session to become available",
"No sessions available. Creating session",
"No sessions available in pool. Creating session",
]
self.assertSpanEvents("pool.Get", wantEventNames)

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

def test_spans_get_non_empty_session_exists(self):
# Tests the spans produces when you invoke pool.bind
# and then insert a session into the pool.
pool = self._make_one()
database = _Database("name")
previous = _Session(database)
Expand Down Expand Up @@ -526,6 +532,7 @@ def test_put_empty(self):
self.assertFalse(pool._sessions.empty())

def test_spans_put_empty(self):
# Tests the spans produced when you put sessions into an empty pool.
pool = self._make_one()
database = _Database("name")
pool.bind(database)
Expand Down Expand Up @@ -555,6 +562,8 @@ def test_put_full(self):
self.assertIs(pool.get(), older)

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

def test_spans_get_empty_pool(self):
def test_spans_get_and_leave_empty_pool(self):
# This scenario tests the spans generated from pulling a span
# out the pool and leaving it empty.
pool = self._make_one()
database = _Database("name")
session1 = _Session(database)
Expand Down

0 comments on commit 2d074ba

Please sign in to comment.