Skip to content

Commit f1e3826

Browse files
committed
Fix tests
1 parent 1fac5bd commit f1e3826

File tree

2 files changed

+48
-8
lines changed

2 files changed

+48
-8
lines changed

tests/aio/test_session_pool.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ async def test_close_basic_logic_case_1(driver):
6262
waiter = asyncio.ensure_future(pool.acquire())
6363

6464
await pool.stop()
65-
waiter_sess = waiter.result()
66-
assert not waiter_sess.initialized()
67-
after_stop = await pool.acquire()
68-
assert not after_stop.initialized()
65+
66+
with pytest.raises(ValueError):
67+
waiter.result()
68+
69+
with pytest.raises(ValueError):
70+
await pool.acquire()
6971

7072
await pool.release(s)
71-
await pool.release(after_stop)
72-
await pool.release(waiter_sess)
7373
assert pool._active_count == 0
7474

7575

@@ -106,9 +106,9 @@ async def test_close_basic_logic_case_2(driver):
106106

107107
assert pool._active_count == 0
108108

109-
sess = await pool.acquire()
109+
with pytest.raises(ValueError):
110+
await pool.acquire()
110111

111-
assert not sess.initialized()
112112
await pool.stop()
113113

114114

tests/session_pool.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import pytest
2+
3+
import ydb
4+
5+
6+
def test_close_basic_logic_case_1(driver_sync):
7+
pool = ydb.SessionPool(driver_sync, 1)
8+
s = pool.acquire()
9+
10+
pool.stop()
11+
12+
with pytest.raises(ValueError):
13+
pool.acquire()
14+
15+
pool.release(s)
16+
assert pool._pool_impl._active_count == 0
17+
18+
19+
def test_close_basic_logic_case_2(driver_sync):
20+
pool = ydb.SessionPool(driver_sync, 10)
21+
acquired = []
22+
23+
for _ in range(10):
24+
acquired.append(pool.acquire())
25+
26+
for _ in range(3):
27+
pool.release(acquired.pop(-1))
28+
29+
pool.stop()
30+
assert pool._pool_impl._active_count == 7
31+
32+
while acquired:
33+
pool.release(acquired.pop(-1))
34+
35+
assert pool._pool_impl._active_count == 0
36+
37+
with pytest.raises(ValueError):
38+
pool.acquire()
39+
40+
pool.stop()

0 commit comments

Comments
 (0)