Skip to content

Commit 5693d4b

Browse files
committed
refactor cursors
1 parent 96ed1ef commit 5693d4b

File tree

5 files changed

+317
-547
lines changed

5 files changed

+317
-547
lines changed

tests/conftest.py

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class YDBContainer(DbContainer):
2121
def __init__(
2222
self,
2323
name: str | None = None,
24-
port: str = "2135",
24+
port: str = "2136",
2525
image: str = "ydbplatform/local-ydb:trunk",
2626
**kwargs: Any,
2727
) -> None:
@@ -104,12 +104,12 @@ def ydb_container(
104104
yield ydb_container
105105

106106

107-
@pytest.fixture
107+
@pytest.fixture(scope="session")
108108
def connection_string(ydb_container: YDBContainer) -> str:
109109
return ydb_container.get_connection_string()
110110

111111

112-
@pytest.fixture
112+
@pytest.fixture(scope="session")
113113
def connection_kwargs(ydb_container: YDBContainer) -> dict:
114114
return {
115115
"host": ydb_container.get_ydb_host(),
@@ -120,12 +120,11 @@ def connection_kwargs(ydb_container: YDBContainer) -> dict:
120120

121121
@pytest.fixture
122122
async def driver(
123-
ydb_container: YDBContainer, event_loop: AbstractEventLoop
123+
connection_string: str,
124+
event_loop: AbstractEventLoop,
124125
) -> AsyncGenerator[ydb.aio.Driver]:
125-
driver = ydb.aio.Driver(
126-
connection_string=ydb_container.get_connection_string()
127-
)
128-
await driver.wait(timeout=15, fail_fast=True)
126+
driver = ydb.aio.Driver(connection_string=connection_string)
127+
await driver.wait(timeout=10)
129128

130129
yield driver
131130

@@ -135,12 +134,10 @@ async def driver(
135134

136135
@pytest.fixture
137136
def driver_sync(
138-
ydb_container: YDBContainer,
137+
connection_string: str,
139138
) -> Generator[ydb.Driver]:
140-
driver = ydb.Driver(
141-
connection_string=ydb_container.get_connection_string()
142-
)
143-
driver.wait(timeout=15, fail_fast=True)
139+
driver = ydb.Driver(connection_string=connection_string)
140+
driver.wait(timeout=10)
144141

145142
yield driver
146143

@@ -187,25 +184,3 @@ def session_pool_sync(
187184
"""
188185
)
189186
yield session_pool
190-
191-
192-
@pytest.fixture
193-
async def session(
194-
session_pool: ydb.aio.QuerySessionPool,
195-
) -> AsyncGenerator[ydb.aio.QuerySession]:
196-
session = await session_pool.acquire()
197-
198-
yield session
199-
200-
await session_pool.release(session)
201-
202-
203-
@pytest.fixture
204-
def session_sync(
205-
session_pool_sync: ydb.QuerySessionPool,
206-
) -> Generator[ydb.QuerySession]:
207-
session = session_pool_sync.acquire()
208-
209-
yield session
210-
211-
session_pool_sync.release(session)

0 commit comments

Comments
 (0)