Skip to content

Commit 55d0b4a

Browse files
committed
test create table with not null primary key
1 parent d494f08 commit 55d0b4a

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

tests/conftest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,17 @@ async def driver(endpoint, database, event_loop):
9696
yield driver
9797

9898
await driver.stop(timeout=10)
99+
100+
@pytest.fixture()
101+
async def driver_sync(endpoint, database, event_loop):
102+
driver_config = ydb.DriverConfig(
103+
endpoint,
104+
database,
105+
)
106+
107+
driver = ydb.Driver(driver_config=driver_config)
108+
driver.wait(timeout=15)
109+
110+
yield driver
111+
112+
driver.stop(timeout=10)

tests/table/table_test.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import ydb
2+
3+
4+
class TestTable:
5+
def test_create_table_with_not_null_primary_key_by_api(self, driver_sync, database):
6+
table_path = database + "/test_table"
7+
8+
def create_table(session: ydb.Session):
9+
try:
10+
session.drop_table(table_path)
11+
except ydb.issues.SchemeError:
12+
pass
13+
14+
description = (
15+
ydb.TableDescription()
16+
.with_primary_keys("key1")
17+
.with_columns(
18+
ydb.Column("key1", ydb.PrimitiveType.Uint64),
19+
ydb.Column("value", ydb.OptionalType(ydb.PrimitiveType.Utf8)),
20+
)
21+
)
22+
23+
session.create_table(table_path, description)
24+
25+
with ydb.SessionPool(driver_sync) as pool:
26+
pool.retry_operation_sync(create_table)
27+
28+
res = driver_sync.scheme_client.describe_path(table_path)
29+
assert res.type == ydb.scheme.SchemeEntryType.TABLE

0 commit comments

Comments
 (0)