From b3e4e816860241a9c082e2b08d5f3213dfc9c207 Mon Sep 17 00:00:00 2001 From: Soumyendra Shrivastava Date: Mon, 4 Mar 2024 16:57:01 -0800 Subject: [PATCH] SDK/python: Add test for invalid bucket name Signed-off-by: Soumyendra Shrivastava --- python/tests/integration/sdk/remote_enabled_test.py | 3 +-- python/tests/integration/sdk/test_bucket_ops.py | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/python/tests/integration/sdk/remote_enabled_test.py b/python/tests/integration/sdk/remote_enabled_test.py index dbd418a23b..2e4fa8eb6e 100644 --- a/python/tests/integration/sdk/remote_enabled_test.py +++ b/python/tests/integration/sdk/remote_enabled_test.py @@ -6,7 +6,6 @@ import boto3 from aistore.sdk.const import PROVIDER_AIS - from aistore import Client from tests.integration import ( REMOTE_SET, @@ -68,8 +67,8 @@ def _create_bucket(self, bck_name, provider=PROVIDER_AIS): provider: Provider for new bucket """ bck = self.client.bucket(bck_name, provider=provider) - self.buckets.append(bck_name) bck.create() + self.buckets.append(bck_name) return bck def _create_objects(self, num_obj=OBJECT_COUNT, suffix=""): diff --git a/python/tests/integration/sdk/test_bucket_ops.py b/python/tests/integration/sdk/test_bucket_ops.py index 274e3208e9..81fd7ef195 100644 --- a/python/tests/integration/sdk/test_bucket_ops.py +++ b/python/tests/integration/sdk/test_bucket_ops.py @@ -64,6 +64,13 @@ def test_bucket(self): bucket_names = {bck.name for bck in res} self.assertIn(new_bck_name, bucket_names) + @test_cases( + "*", ".", "", " ", "bucket/name", "bucket and name", "#name", "$name", "~name" + ) + def test_create_bucket_invalid_name(self, testcase): + with self.assertRaises(AISError): + self._create_bucket(testcase) + def test_bucket_invalid_name(self): with self.assertRaises(ErrBckNotFound): self.client.bucket("INVALID_BCK_NAME").list_objects()