From 381b227fd25780cf8b0eb95f2074841c5740642b Mon Sep 17 00:00:00 2001 From: Timofey Koolin Date: Thu, 2 Mar 2023 18:42:46 +0300 Subject: [PATCH 1/2] test create table with not null primary key --- tests/conftest.py | 14 ++++++++++++++ tests/table/table_test.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 tests/table/table_test.py diff --git a/tests/conftest.py b/tests/conftest.py index 336ffdae..378c1264 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -96,3 +96,17 @@ async def driver(endpoint, database, event_loop): yield driver await driver.stop(timeout=10) + +@pytest.fixture() +async def driver_sync(endpoint, database, event_loop): + driver_config = ydb.DriverConfig( + endpoint, + database, + ) + + driver = ydb.Driver(driver_config=driver_config) + driver.wait(timeout=15) + + yield driver + + driver.stop(timeout=10) diff --git a/tests/table/table_test.py b/tests/table/table_test.py new file mode 100644 index 00000000..97bdcc88 --- /dev/null +++ b/tests/table/table_test.py @@ -0,0 +1,29 @@ +import ydb + + +class TestTable: + def test_create_table_with_not_null_primary_key_by_api(self, driver_sync, database): + table_path = database + "/test_table" + + def create_table(session: ydb.Session): + try: + session.drop_table(table_path) + except ydb.issues.SchemeError: + pass + + description = ( + ydb.TableDescription() + .with_primary_keys("key1") + .with_columns( + ydb.Column("key1", ydb.PrimitiveType.Uint64), + ydb.Column("value", ydb.OptionalType(ydb.PrimitiveType.Utf8)), + ) + ) + + session.create_table(table_path, description) + + with ydb.SessionPool(driver_sync) as pool: + pool.retry_operation_sync(create_table) + + res = driver_sync.scheme_client.describe_path(table_path) + assert res.type == ydb.scheme.SchemeEntryType.TABLE From 421df9a096798877336f3bb0b61801ce0b2cdca3 Mon Sep 17 00:00:00 2001 From: Timofey Koolin Date: Thu, 2 Mar 2023 18:51:09 +0300 Subject: [PATCH 2/2] style --- tests/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/conftest.py b/tests/conftest.py index 378c1264..df21ba0d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -97,6 +97,7 @@ async def driver(endpoint, database, event_loop): await driver.stop(timeout=10) + @pytest.fixture() async def driver_sync(endpoint, database, event_loop): driver_config = ydb.DriverConfig(