From 2e27d1cbacf37241e4939ceacdb335e9a14d786d Mon Sep 17 00:00:00 2001 From: ptiurin Date: Thu, 9 May 2024 13:40:28 +0100 Subject: [PATCH] test: Fix sa character limit in tests --- tests/integration/dbapi/async/V2/conftest.py | 7 +++++-- tests/integration/dbapi/sync/V2/conftest.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/integration/dbapi/async/V2/conftest.py b/tests/integration/dbapi/async/V2/conftest.py index 725e29f24a..17fd3c8e85 100644 --- a/tests/integration/dbapi/async/V2/conftest.py +++ b/tests/integration/dbapi/async/V2/conftest.py @@ -1,4 +1,6 @@ -from random import choice, randint +import random +import string +from random import choice from typing import Tuple from pytest import fixture @@ -120,7 +122,8 @@ async def service_account_no_user( database_name: str, ) -> Tuple[str, Secret]: # function-level fixture so we need to make sa name is unique - sa_account_name = f"{database_name}_sa_no_user_{randint(0, 1000)}" + randomness = "".join(random.choices(string.ascii_letters + string.digits, k=2)) + sa_account_name = f"{database_name}_sa_no_user_{randomness}" with connection_system_engine_no_db.cursor() as cursor: await cursor.execute( f'CREATE SERVICE ACCOUNT "{sa_account_name}" ' diff --git a/tests/integration/dbapi/sync/V2/conftest.py b/tests/integration/dbapi/sync/V2/conftest.py index 6ac4fac94b..87a8961c49 100644 --- a/tests/integration/dbapi/sync/V2/conftest.py +++ b/tests/integration/dbapi/sync/V2/conftest.py @@ -1,4 +1,6 @@ -from random import choice, randint +import random +import string +from random import choice from typing import Tuple from pytest import fixture @@ -120,7 +122,8 @@ def service_account_no_user( database_name: str, ) -> Tuple[str, Secret]: # function-level fixture so we need to make sa name is unique - sa_account_name = f"{database_name}_sa_no_user_{randint(0, 1000)}" + randomness = "".join(random.choices(string.ascii_letters + string.digits, k=2)) + sa_account_name = f"{database_name}_sa_no_user_{randomness}" with connection_system_engine_no_db.cursor() as cursor: cursor.execute( f'CREATE SERVICE ACCOUNT "{sa_account_name}" '