Skip to content

Commit 54bf667

Browse files
committed
review fixes
1 parent e757eef commit 54bf667

File tree

3 files changed

+24
-30
lines changed

3 files changed

+24
-30
lines changed

tests/query/test_query_client_settings.py

+22-30
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import ydb
44

5-
from datetime import date, datetime, timedelta, timezone
5+
from datetime import date, datetime, timedelta
66

77

88
@pytest.fixture
@@ -31,37 +31,27 @@ def settings_off():
3131
return settings
3232

3333

34-
test_td = timedelta(microseconds=-100)
35-
test_now = datetime.utcnow()
36-
test_today = test_now.date()
37-
test_dt_today = datetime.today()
38-
tz4h = timezone(timedelta(hours=4))
39-
40-
4134
params = pytest.mark.parametrize(
42-
"value,ydb_type,casted_result,uncasted_type",
35+
"value,ydb_type,casted_result,uncasted_result",
4336
[
44-
(test_today, "Date", test_today, int),
45-
(365, "Date", date(1971, 1, 1), int),
46-
(3600 * 24 * 365, "Datetime", datetime(1971, 1, 1, 0, 0), int),
47-
(datetime(1970, 1, 1, 4, 0, tzinfo=tz4h), "Timestamp", datetime(1970, 1, 1, 0, 0), int),
48-
(test_td, "Interval", test_td, int),
49-
(test_now, "Timestamp", test_now, int),
37+
(365, "Date", date(1971, 1, 1), 365),
38+
(3600 * 24 * 365, "Datetime", datetime(1971, 1, 1, 0, 0), 3600 * 24 * 365),
39+
(timedelta(seconds=1), "Interval", timedelta(seconds=1), 1000000),
5040
(
5141
1511789040123456,
5242
"Timestamp",
5343
datetime.fromisoformat("2017-11-27 13:24:00.123456"),
54-
int,
44+
1511789040123456,
5545
),
56-
('{"foo": "bar"}', "Json", {"foo": "bar"}, str),
57-
('{"foo": "bar"}', "JsonDocument", {"foo": "bar"}, str),
46+
('{"foo": "bar"}', "Json", {"foo": "bar"}, '{"foo": "bar"}'),
47+
('{"foo": "bar"}', "JsonDocument", {"foo": "bar"}, '{"foo":"bar"}'),
5848
],
5949
)
6050

6151

6252
class TestQueryClientSettings:
6353
@params
64-
def test_driver_turn_on(self, driver_sync, settings_on, value, ydb_type, casted_result, uncasted_type):
54+
def test_driver_turn_on(self, driver_sync, settings_on, value, ydb_type, casted_result, uncasted_result):
6555
driver_sync._driver_config.query_client_settings = settings_on
6656
pool = ydb.QuerySessionPool(driver_sync)
6757
result = pool.execute_with_retries(
@@ -72,18 +62,18 @@ def test_driver_turn_on(self, driver_sync, settings_on, value, ydb_type, casted_
7262
pool.stop()
7363

7464
@params
75-
def test_driver_turn_off(self, driver_sync, settings_off, value, ydb_type, casted_result, uncasted_type):
65+
def test_driver_turn_off(self, driver_sync, settings_off, value, ydb_type, casted_result, uncasted_result):
7666
driver_sync._driver_config.query_client_settings = settings_off
7767
pool = ydb.QuerySessionPool(driver_sync)
7868
result = pool.execute_with_retries(
7969
f"DECLARE $param as {ydb_type}; SELECT $param as value",
8070
{"$param": (value, getattr(ydb.PrimitiveType, ydb_type))},
8171
)
82-
assert type(result[0].rows[0].value) == uncasted_type
72+
assert result[0].rows[0].value == uncasted_result
8373
pool.stop()
8474

8575
@params
86-
def test_session_pool_turn_on(self, driver_sync, settings_on, value, ydb_type, casted_result, uncasted_type):
76+
def test_session_pool_turn_on(self, driver_sync, settings_on, value, ydb_type, casted_result, uncasted_result):
8777
pool = ydb.QuerySessionPool(driver_sync, query_client_settings=settings_on)
8878
result = pool.execute_with_retries(
8979
f"DECLARE $param as {ydb_type}; SELECT $param as value",
@@ -93,18 +83,18 @@ def test_session_pool_turn_on(self, driver_sync, settings_on, value, ydb_type, c
9383
pool.stop()
9484

9585
@params
96-
def test_session_pool_turn_off(self, driver_sync, settings_off, value, ydb_type, casted_result, uncasted_type):
86+
def test_session_pool_turn_off(self, driver_sync, settings_off, value, ydb_type, casted_result, uncasted_result):
9787
pool = ydb.QuerySessionPool(driver_sync, query_client_settings=settings_off)
9888
result = pool.execute_with_retries(
9989
f"DECLARE $param as {ydb_type}; SELECT $param as value",
10090
{"$param": (value, getattr(ydb.PrimitiveType, ydb_type))},
10191
)
102-
assert type(result[0].rows[0].value) == uncasted_type
92+
assert result[0].rows[0].value == uncasted_result
10393
pool.stop()
10494

10595
@pytest.mark.asyncio
10696
@params
107-
async def test_driver_async_turn_on(self, driver, settings_on, value, ydb_type, casted_result, uncasted_type):
97+
async def test_driver_async_turn_on(self, driver, settings_on, value, ydb_type, casted_result, uncasted_result):
10898
driver._driver_config.query_client_settings = settings_on
10999
pool = ydb.aio.QuerySessionPool(driver)
110100
result = await pool.execute_with_retries(
@@ -116,19 +106,21 @@ async def test_driver_async_turn_on(self, driver, settings_on, value, ydb_type,
116106

117107
@pytest.mark.asyncio
118108
@params
119-
async def test_driver_async_turn_off(self, driver, settings_off, value, ydb_type, casted_result, uncasted_type):
109+
async def test_driver_async_turn_off(self, driver, settings_off, value, ydb_type, casted_result, uncasted_result):
120110
driver._driver_config.query_client_settings = settings_off
121111
pool = ydb.aio.QuerySessionPool(driver)
122112
result = await pool.execute_with_retries(
123113
f"DECLARE $param as {ydb_type}; SELECT $param as value",
124114
{"$param": (value, getattr(ydb.PrimitiveType, ydb_type))},
125115
)
126-
assert type(result[0].rows[0].value) == uncasted_type
116+
assert result[0].rows[0].value == uncasted_result
127117
await pool.stop()
128118

129119
@pytest.mark.asyncio
130120
@params
131-
async def test_session_pool_async_turn_on(self, driver, settings_on, value, ydb_type, casted_result, uncasted_type):
121+
async def test_session_pool_async_turn_on(
122+
self, driver, settings_on, value, ydb_type, casted_result, uncasted_result
123+
):
132124
pool = ydb.aio.QuerySessionPool(driver, query_client_settings=settings_on)
133125
result = await pool.execute_with_retries(
134126
f"DECLARE $param as {ydb_type}; SELECT $param as value",
@@ -140,12 +132,12 @@ async def test_session_pool_async_turn_on(self, driver, settings_on, value, ydb_
140132
@pytest.mark.asyncio
141133
@params
142134
async def test_session_pool_async_turn_off(
143-
self, driver, settings_off, value, ydb_type, casted_result, uncasted_type
135+
self, driver, settings_off, value, ydb_type, casted_result, uncasted_result
144136
):
145137
pool = ydb.aio.QuerySessionPool(driver, query_client_settings=settings_off)
146138
result = await pool.execute_with_retries(
147139
f"DECLARE $param as {ydb_type}; SELECT $param as value",
148140
{"$param": (value, getattr(ydb.PrimitiveType, ydb_type))},
149141
)
150-
assert type(result[0].rows[0].value) == uncasted_type
142+
assert result[0].rows[0].value == uncasted_result
151143
await pool.stop()

ydb/aio/query/pool.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __init__(
2727
self,
2828
driver: common_utils.SupportedDriverType,
2929
size: int = 100,
30+
*,
3031
query_client_settings: Optional[QueryClientSettings] = None,
3132
):
3233
"""

ydb/query/pool.py

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def __init__(
3232
self,
3333
driver: common_utils.SupportedDriverType,
3434
size: int = 100,
35+
*,
3536
query_client_settings: Optional[QueryClientSettings] = None,
3637
):
3738
"""

0 commit comments

Comments
 (0)