From 38d23d1b4afb139635adc883230af6e3ad0d1eb7 Mon Sep 17 00:00:00 2001 From: "guangjun.hgj" Date: Thu, 14 Jul 2022 16:48:46 +0800 Subject: [PATCH] update testcase. --- tests/common.py | 15 +++++---- tests/test_api_base.py | 12 +++---- tests/test_async_fetch_task.py | 10 +++--- tests/test_bucket.py | 22 ++++++------- tests/test_bucket_inventory.py | 14 ++++---- tests/test_bucket_meta_query.py | 2 +- tests/test_bucket_replication.py | 4 +-- tests/test_bucket_versioning.py | 8 ++--- tests/test_credentials_provider.py | 4 +-- tests/test_crypto_object.py | 4 +-- tests/test_iterator.py | 2 +- tests/test_lifecycle_versioning.py | 6 ++-- tests/test_list_objects_v2.py | 8 ++--- tests/test_live_channel.py | 2 +- tests/test_multipart.py | 2 +- tests/test_object.py | 24 +++++++------- tests/test_object_request_payment.py | 4 +-- tests/test_object_request_payment_versions.py | 2 +- tests/test_object_versioning.py | 32 +++++++++---------- tests/test_proxy.py | 2 +- tests/test_server_side_encryotion.py | 12 +++---- tests/test_sts.py | 2 +- tests/test_upload.py | 2 +- 23 files changed, 98 insertions(+), 97 deletions(-) diff --git a/tests/common.py b/tests/common.py index 69b54e18..819bf814 100644 --- a/tests/common.py +++ b/tests/common.py @@ -72,11 +72,11 @@ def random_string(n): return ''.join(random.choice(string.ascii_lowercase) for i in range(n)) -OSS_BUCKET = '' +OSS_BUCKET_BASE = '' if OSS_TEST_BUCKET is None: - OSS_BUCKET = 'oss-python-sdk-'+random_string(10) + OSS_BUCKET_BASE = 'oss-python-sdk-'+random_string(6) else: - OSS_BUCKET = OSS_TEST_BUCKET + random_string(10) + OSS_BUCKET_BASE = OSS_TEST_BUCKET + random_string(6) def random_bytes(n): return oss2.to_bytes(random_string(n)) @@ -174,7 +174,8 @@ def setUp(self): global OSS_AUTH_VERSION OSS_AUTH_VERSION = os.getenv('OSS_TEST_AUTH_VERSION') - self.bucket = oss2.Bucket(oss2.make_auth(OSS_ID, OSS_SECRET, OSS_AUTH_VERSION), OSS_ENDPOINT, OSS_BUCKET) + self.OSS_BUCKET = OSS_BUCKET_BASE + random_string(4) + self.bucket = oss2.Bucket(oss2.make_auth(OSS_ID, OSS_SECRET, OSS_AUTH_VERSION), OSS_ENDPOINT, self.OSS_BUCKET) try: self.bucket.create_bucket() @@ -182,10 +183,10 @@ def setUp(self): pass self.rsa_crypto_bucket = oss2.CryptoBucket(oss2.make_auth(OSS_ID, OSS_SECRET, OSS_AUTH_VERSION), OSS_ENDPOINT, - OSS_BUCKET, crypto_provider=oss2.RsaProvider(key_pair)) + self.OSS_BUCKET, crypto_provider=oss2.RsaProvider(key_pair)) self.kms_crypto_bucket = oss2.CryptoBucket(oss2.make_auth(OSS_ID, OSS_SECRET, OSS_AUTH_VERSION), OSS_ENDPOINT, - OSS_BUCKET, crypto_provider=oss2.AliKMSProvider(OSS_ID, OSS_SECRET, + self.OSS_BUCKET, crypto_provider=oss2.AliKMSProvider(OSS_ID, OSS_SECRET, OSS_REGION, OSS_CMK)) self.key_list = [] @@ -196,7 +197,7 @@ def tearDown(self): oss2.utils.silently_remove(temp_file) clean_and_delete_bucket(self.bucket) - clean_and_delete_bucket_by_prefix(OSS_BUCKET + "-test-") + clean_and_delete_bucket_by_prefix(self.OSS_BUCKET + "-test-") def random_key(self, suffix=''): key = self.prefix + random_string(12) + suffix diff --git a/tests/test_api_base.py b/tests/test_api_base.py index 98dd11cc..3ffedb4d 100644 --- a/tests/test_api_base.py +++ b/tests/test_api_base.py @@ -11,11 +11,11 @@ class TestApiBase(OssTestCase): if OSS_CNAME: def test_cname_bucket(self): - bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), OSS_CNAME, OSS_BUCKET, is_cname=True) + bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), OSS_CNAME, self.OSS_BUCKET, is_cname=True) bucket.get_bucket_acl() def test_cname_object(self): - bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), OSS_CNAME, OSS_BUCKET, is_cname=True) + bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), OSS_CNAME, self.OSS_BUCKET, is_cname=True) bucket.put_object('hello.txt', 'hello world') def test_https(self): @@ -78,13 +78,13 @@ def test_check_endpoint(self): 'test-bucket') def test_whitespace(self): - bucket = oss2.Bucket(oss2.Auth(OSS_ID, ' ' + OSS_SECRET + ' '), OSS_ENDPOINT, OSS_BUCKET) + bucket = oss2.Bucket(oss2.Auth(OSS_ID, ' ' + OSS_SECRET + ' '), OSS_ENDPOINT, self.OSS_BUCKET) bucket.get_bucket_acl() - bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), ' ' + OSS_ENDPOINT + ' ', OSS_BUCKET) + bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), ' ' + OSS_ENDPOINT + ' ', self.OSS_BUCKET) bucket.get_bucket_acl() - bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), OSS_ENDPOINT, ' ' + OSS_BUCKET + ' ') + bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), OSS_ENDPOINT, ' ' + self.OSS_BUCKET + ' ') bucket.get_bucket_acl() if sys.version_info >= (3, 3): @@ -111,7 +111,7 @@ def do_request(session_self, req, timeout): # 加app_name assert_found = True - bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), OSS_ENDPOINT, OSS_BUCKET, + bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), OSS_ENDPOINT, self.OSS_BUCKET, app_name=app) self.assertRaises(oss2.exceptions.ClientError, bucket.get_bucket_acl) diff --git a/tests/test_async_fetch_task.py b/tests/test_async_fetch_task.py index c115a51f..fa3723d8 100644 --- a/tests/test_async_fetch_task.py +++ b/tests/test_async_fetch_task.py @@ -24,7 +24,7 @@ def setUp(self): def test_async_fetch_task(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-async-fetch-task" + bucket_name = self.OSS_BUCKET + "-test-async-fetch-task" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket() @@ -52,7 +52,7 @@ def test_async_fetch_task(self): def test_async_fetch_task_with_few_argument(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-async-fetch-task" + bucket_name = self.OSS_BUCKET + "-test-async-fetch-task" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket() @@ -80,7 +80,7 @@ def test_async_fetch_task_with_few_argument(self): def test_fetch_success_callback_failed_state(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-async-fetch-task-callback" + bucket_name = self.OSS_BUCKET + "-test-async-fetch-task-callback" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket() @@ -112,7 +112,7 @@ def test_fetch_success_callback_failed_state(self): def test_failed_state(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-async-fetch-task-callback" + bucket_name = self.OSS_BUCKET + "-test-async-fetch-task-callback" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket() @@ -134,7 +134,7 @@ def test_failed_state(self): def test_ignore_same_key(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-async-fetch-task" + bucket_name = self.OSS_BUCKET + "-test-async-fetch-task" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket() diff --git a/tests/test_bucket.py b/tests/test_bucket.py index f03a91e6..08d1079d 100644 --- a/tests/test_bucket.py +++ b/tests/test_bucket.py @@ -11,7 +11,7 @@ class TestBucket(OssTestCase): def test_bucket(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-bucket" + bucket_name = self.OSS_BUCKET + "-test-bucket" bucket = oss2.Bucket(auth, OSS_ENDPOINT, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -35,7 +35,7 @@ def test_bucket(self): def test_bucket_with_storage_class(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-storage-class" + bucket_name = self.OSS_BUCKET + "-test-storage-class" bucket = oss2.Bucket(auth, OSS_ENDPOINT, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE, oss2.models.BucketCreateConfig(oss2.BUCKET_STORAGE_CLASS_IA)) @@ -63,7 +63,7 @@ def test_bucket_with_storage_class(self): def test_bucket_with_data_redundancy_type(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-redundancy-type" + bucket_name = self.OSS_BUCKET + "-test-redundancy-type" bucket = oss2.Bucket(auth, OSS_ENDPOINT, bucket_name) # LRS @@ -86,7 +86,7 @@ def test_bucket_with_data_redundancy_type(self): def test_acl(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-acl" + bucket_name = self.OSS_BUCKET + "-test-acl" bucket = oss2.Bucket(auth, OSS_ENDPOINT, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PUBLIC_READ) @@ -104,7 +104,7 @@ def test_acl(self): bucket.delete_bucket() def test_logging(self): - bucket_name = OSS_BUCKET + "-test-logging" + bucket_name = self.OSS_BUCKET + "-test-logging" other_bucket = oss2.Bucket(self.bucket.auth, OSS_ENDPOINT, bucket_name) other_bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -560,7 +560,7 @@ def test_cors(self): def test_bucket_stat(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-stat" + bucket_name = self.OSS_BUCKET + "-test-stat" bucket = oss2.Bucket(auth, OSS_ENDPOINT, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -587,7 +587,7 @@ def test_bucket_stat(self): def test_bucket_stat_all_param(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-stat-all" + bucket_name = self.OSS_BUCKET + "-test-stat-all" bucket = oss2.Bucket(auth, OSS_ENDPOINT, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -627,7 +627,7 @@ def test_bucket_stat_all_param(self): def test_bucket_info(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-info" + bucket_name = self.OSS_BUCKET + "-test-info" bucket = oss2.Bucket(auth, OSS_ENDPOINT, bucket_name) self.assertRaises(oss2.exceptions.NoSuchBucket, bucket.get_bucket_info) @@ -801,14 +801,14 @@ def test_list_bucket_with_tagging(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) service = oss2.Service(auth, OSS_ENDPOINT) - bucket_name1 = OSS_BUCKET + "-test-with-tagging-1" + bucket_name1 = self.OSS_BUCKET + "-test-with-tagging-1" bucket1 = oss2.Bucket(auth, OSS_ENDPOINT, bucket_name1) bucket1.create_bucket(oss2.BUCKET_ACL_PRIVATE) wait_meta_sync() - bucket_name2 = OSS_BUCKET + "-test-with-tagging-2" + bucket_name2 = self.OSS_BUCKET + "-test-with-tagging-2" bucket2 = oss2.Bucket(auth, OSS_ENDPOINT, bucket_name2) bucket2.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -851,7 +851,7 @@ def test_list_bucket_with_tagging(self): def test_bucket_policy(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-policy" + bucket_name = self.OSS_BUCKET + "-test-policy" bucket = oss2.Bucket(auth, OSS_ENDPOINT, bucket_name) self.assertRaises(oss2.exceptions.NoSuchBucket, bucket.get_bucket_info) diff --git a/tests/test_bucket_inventory.py b/tests/test_bucket_inventory.py index 03fc4e55..44f1d3ee 100644 --- a/tests/test_bucket_inventory.py +++ b/tests/test_bucket_inventory.py @@ -25,14 +25,14 @@ class TestBucketInventory(OssTestCase): def setUp(self): OssTestCase.setUp(self) self.endpoint = OSS_ENDPOINT - bucket_name = OSS_BUCKET + "-test-inventory" + bucket_name = self.OSS_BUCKET + "-test-inventory" self.bucket1 = oss2.Bucket(oss2.make_auth(OSS_ID, OSS_SECRET, OSS_AUTH_VERSION), self.endpoint, bucket_name) self.bucket1.create_bucket() def test_bucket_inventory(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - dest_bucket_name = OSS_BUCKET + "-test-inventory-dest" + dest_bucket_name = self.OSS_BUCKET + "-test-inventory-dest" dest_bucket = oss2.Bucket(auth, self.endpoint, dest_bucket_name) dest_bucket.create_bucket() @@ -91,7 +91,7 @@ def test_error_bucket_encryption(self): def test_list_few_bucket_inventory(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - dest_bucket_name = OSS_BUCKET + "-test-inventory-dest" + dest_bucket_name = self.OSS_BUCKET + "-test-inventory-dest" dest_bucket = oss2.Bucket(auth, self.endpoint, dest_bucket_name) dest_bucket.create_bucket() time.sleep(5) @@ -105,7 +105,7 @@ def test_list_few_bucket_inventory(self): bucket_destination = InventoryBucketDestination( account_id=OSS_INVENTORY_BUCKET_DESTINATION_ACCOUNT, role_arn=OSS_INVENTORY_BUCKET_DESTINATION_ARN, - bucket=OSS_BUCKET, + bucket=self.OSS_BUCKET, inventory_format=INVENTORY_FORMAT_CSV, prefix="destination-prefix", sse_kms_encryption=InventoryServerSideEncryptionKMS(OSS_CMK)) @@ -139,7 +139,7 @@ def test_list_few_bucket_inventory(self): def test_list_lot_bucket_inventory(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - dest_bucket_name = OSS_BUCKET + "-test-inventory-dest" + dest_bucket_name = self.OSS_BUCKET + "-test-inventory-dest" dest_bucket = oss2.Bucket(auth, self.endpoint, dest_bucket_name) dest_bucket.create_bucket() @@ -152,7 +152,7 @@ def test_list_lot_bucket_inventory(self): bucket_destination = InventoryBucketDestination( account_id=OSS_INVENTORY_BUCKET_DESTINATION_ACCOUNT, role_arn=OSS_INVENTORY_BUCKET_DESTINATION_ARN, - bucket=OSS_BUCKET, + bucket=self.OSS_BUCKET, inventory_format=INVENTORY_FORMAT_CSV, prefix="destination-prefix") @@ -184,7 +184,7 @@ def test_list_lot_bucket_inventory(self): def test_list_none_inventory(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - dest_bucket_name = OSS_BUCKET + "-test-none-inventory" + dest_bucket_name = self.OSS_BUCKET + "-test-none-inventory" dest_bucket = oss2.Bucket(auth, self.endpoint, dest_bucket_name) dest_bucket.create_bucket() self.assertRaises(oss2.exceptions.NoSuchInventory, dest_bucket.list_bucket_inventory_configurations) diff --git a/tests/test_bucket_meta_query.py b/tests/test_bucket_meta_query.py index 87f9bca3..4bb8ec87 100644 --- a/tests/test_bucket_meta_query.py +++ b/tests/test_bucket_meta_query.py @@ -47,7 +47,7 @@ def test_1_bucket_meta_query(self): def test_2_bucket_meta_query_aggregation(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - dest_bucket_name = OSS_BUCKET + "-test-meta-query" + dest_bucket_name = self.OSS_BUCKET + "-test-meta-query" dest_bucket = oss2.Bucket(auth, OSS_ENDPOINT, dest_bucket_name) dest_bucket.create_bucket() diff --git a/tests/test_bucket_replication.py b/tests/test_bucket_replication.py index 945eb72e..5cc426be 100644 --- a/tests/test_bucket_replication.py +++ b/tests/test_bucket_replication.py @@ -9,13 +9,13 @@ class TestBucketReplication(OssTestCase): def setUp(self): OssTestCase.setUp(self) - source_bucket_name = OSS_BUCKET + '-test-replica-source-' + random_string(10) + source_bucket_name = self.OSS_BUCKET + '-test-replica-source-' + random_string(10) self.source_bucket = oss2.Bucket(oss2.make_auth(OSS_ID, OSS_SECRET, OSS_AUTH_VERSION), OSS_ENDPOINT, source_bucket_name) self.source_bucket.create_bucket() self.replica_endpoint = "oss-ap-south-1" self.transfer_type = 'oss_acc' - self.replica_bucket_name = OSS_BUCKET + "-test-replica-dest-" + random_string(10) + self.replica_bucket_name = self.OSS_BUCKET + "-test-replica-dest-" + random_string(10) self.replica_bucket = oss2.Bucket(oss2.make_auth(OSS_ID, OSS_SECRET, OSS_AUTH_VERSION), self.replica_endpoint + '.aliyuncs.com', self.replica_bucket_name) self.replica_bucket.create_bucket() diff --git a/tests/test_bucket_versioning.py b/tests/test_bucket_versioning.py index c2b1caca..47d70d19 100644 --- a/tests/test_bucket_versioning.py +++ b/tests/test_bucket_versioning.py @@ -17,7 +17,7 @@ def test_bucket_versioning_wrong(self): from oss2.models import BucketVersioningConfig auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-bucket-versioning-wrong" + bucket_name = self.OSS_BUCKET + "-test-bucket-versioning-wrong" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -35,7 +35,7 @@ def test_bucket_versioning(self): from oss2.models import BucketVersioningConfig auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-versioning" + bucket_name = self.OSS_BUCKET + "-test-versioning" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) self.assertRaises(oss2.exceptions.NoSuchBucket, bucket.get_bucket_info) @@ -72,7 +72,7 @@ def test_list_object_versions_wrong(self): from oss2.models import BucketVersioningConfig auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-list-object-versions-wrong" + bucket_name = self.OSS_BUCKET + "-test-list-object-versions-wrong" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) self.assertRaises(oss2.exceptions.NoSuchBucket, bucket.get_bucket_info) @@ -128,7 +128,7 @@ def test_list_object_versions_truncated(self): from oss2.models import BatchDeleteObjectVersionList auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-list-object-versions-truncated" + bucket_name = self.OSS_BUCKET + "-test-list-object-versions-truncated" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) diff --git a/tests/test_credentials_provider.py b/tests/test_credentials_provider.py index 32894e94..d1a29eee 100644 --- a/tests/test_credentials_provider.py +++ b/tests/test_credentials_provider.py @@ -13,7 +13,7 @@ def setUp(self): OssTestCase.setUp(self) self.auth_server_host = self.create_fake_ecs_credentials_url() self.endpoint = OSS_ENDPOINT - self.bucket_name = OSS_BUCKET + "-test-ecs-ram-role" + self.bucket_name = self.OSS_BUCKET + "-test-ecs-ram-role" def tearDown(self): OssTestCase.tearDown(self) @@ -80,7 +80,7 @@ def test_auth(self): test_bucket.delete_object(object_name) test_bucket.delete_bucket() - bucket_name = OSS_BUCKET + '-test-auth-bucket' + bucket_name = self.OSS_BUCKET + '-test-auth-bucket' object_name = 'test-auth-obj' auth1 = oss2.make_auth(OSS_ID, OSS_SECRET, oss2.AUTH_VERSION_1) test_bucket2 = oss2.Bucket(auth1, OSS_ENDPOINT, bucket_name) diff --git a/tests/test_crypto_object.py b/tests/test_crypto_object.py index 7a6f6f89..d0ebe492 100644 --- a/tests/test_crypto_object.py +++ b/tests/test_crypto_object.py @@ -318,7 +318,7 @@ def test_crypto_object_incorrect_description(self): provider_1 = RsaProvider(key_pair={'private_key': private_key_str_1, 'public_key': public_key_str_1}, passphrase=passphrase_1, mat_desc=mat_desc_1) crypto_bucket_1 = oss2.CryptoBucket(oss2.make_auth(OSS_ID, OSS_SECRET, OSS_AUTH_VERSION), OSS_ENDPOINT, - OSS_BUCKET, crypto_provider=provider_1) + self.OSS_BUCKET, crypto_provider=provider_1) private_key_2 = RSA.generate(2048) public_key_2 = private_key_2.publickey() passphrase_2 = random_string(6) @@ -328,7 +328,7 @@ def test_crypto_object_incorrect_description(self): provider_2 = RsaProvider(key_pair={'private_key': private_key_str_2, 'public_key': public_key_str_2}, passphrase=passphrase_2, mat_desc=mat_desc_2) crypto_bucket_2 = oss2.CryptoBucket(oss2.make_auth(OSS_ID, OSS_SECRET, OSS_AUTH_VERSION), OSS_ENDPOINT, - OSS_BUCKET, crypto_provider=provider_2) + self.OSS_BUCKET, crypto_provider=provider_2) key = self.random_key('.js') content = random_bytes(1024) crypto_bucket_1.put_object(key, content) diff --git a/tests/test_iterator.py b/tests/test_iterator.py index 8db14372..e83544d6 100644 --- a/tests/test_iterator.py +++ b/tests/test_iterator.py @@ -12,7 +12,7 @@ class TestIterator(OssTestCase): def test_bucket_iterator(self): service = oss2.Service(oss2.Auth(OSS_ID, OSS_SECRET), OSS_ENDPOINT) - self.assertTrue(OSS_BUCKET in (b.name for b in oss2.BucketIterator(service, max_keys=2))) + self.assertTrue(self.OSS_BUCKET in (b.name for b in oss2.BucketIterator(service, max_keys=2))) def test_object_iterator(self): prefix = self.random_key('/') diff --git a/tests/test_lifecycle_versioning.py b/tests/test_lifecycle_versioning.py index 4aad2e8d..82438a2f 100644 --- a/tests/test_lifecycle_versioning.py +++ b/tests/test_lifecycle_versioning.py @@ -25,7 +25,7 @@ def setUp(self): def test_lifecycle_without_versioning(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-lifecycle-without-versioning" + bucket_name = self.OSS_BUCKET + "-test-lifecycle-without-versioning" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) wait_meta_sync() @@ -68,7 +68,7 @@ def test_lifecycle_without_versioning(self): def test_lifecycle_versioning(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-lifecycle-versioning" + bucket_name = self.OSS_BUCKET + "-test-lifecycle-versioning" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) wait_meta_sync() @@ -97,7 +97,7 @@ def test_lifecycle_versioning(self): def test_lifecycle_veriong_wrong(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-lifecycle-versioning-wrong" + bucket_name = self.OSS_BUCKET + "-test-lifecycle-versioning-wrong" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) wait_meta_sync() diff --git a/tests/test_list_objects_v2.py b/tests/test_list_objects_v2.py index b0117e85..bc1934a7 100644 --- a/tests/test_list_objects_v2.py +++ b/tests/test_list_objects_v2.py @@ -10,7 +10,7 @@ def setUp(self): def test_normal_list_objects(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-normal" + bucket_name = self.OSS_BUCKET + "-test-normal" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket() @@ -79,7 +79,7 @@ def test_normal_list_objects(self): def test_list_with_encoding_type_None(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-list-with-encoding-type-none" + bucket_name = self.OSS_BUCKET + "-test-list-with-encoding-type-none" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket() @@ -99,7 +99,7 @@ def test_list_with_encoding_type_None(self): def test_list_with_error_continuation_token(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-list-with-error-token" + bucket_name = self.OSS_BUCKET + "-test-list-with-error-token" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket() @@ -110,7 +110,7 @@ def test_list_with_error_continuation_token(self): def test_list_object_iterator_v2(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-list-iterator-v2" + bucket_name = self.OSS_BUCKET + "-test-list-iterator-v2" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket() diff --git a/tests/test_live_channel.py b/tests/test_live_channel.py index 46a61996..947d310f 100644 --- a/tests/test_live_channel.py +++ b/tests/test_live_channel.py @@ -87,7 +87,7 @@ def test_get_live_channel(self): def test_list_live_channel(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-list-live-channel" + bucket_name = self.OSS_BUCKET + "-test-list-live-channel" bucket = oss2.Bucket(auth, OSS_ENDPOINT, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) diff --git a/tests/test_multipart.py b/tests/test_multipart.py index 3872c736..53b21586 100644 --- a/tests/test_multipart.py +++ b/tests/test_multipart.py @@ -212,7 +212,7 @@ def test_multipart_with_object_tagging(self): def test_multipart_sequential(self): endpoint = "http://oss-cn-shanghai.aliyuncs.com" auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-multipart-sequential" + bucket_name = self.OSS_BUCKET + "-test-multipart-sequential" bucket = oss2.Bucket(auth, endpoint, bucket_name) bucket.create_bucket() diff --git a/tests/test_object.py b/tests/test_object.py index 37fc19ce..d711552e 100644 --- a/tests/test_object.py +++ b/tests/test_object.py @@ -62,7 +62,7 @@ def assert_result(result): def test_restore_object(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-restore-object" + bucket_name = self.OSS_BUCKET + "-test-restore-object" bucket = oss2.Bucket(auth, OSS_ENDPOINT, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE, oss2.models.BucketCreateConfig(oss2.BUCKET_STORAGE_CLASS_ARCHIVE)) @@ -83,7 +83,7 @@ def test_restore_object_with_config(self): RESTORE_TIER_STANDARD, RESTORE_TIER_BULK) endpoint = "http://oss-ap-southeast-2.aliyuncs.com" - bucket_name = OSS_BUCKET + "-test-restore-1" + bucket_name = self.OSS_BUCKET + "-test-restore-1" bucket = oss2.Bucket(oss2.make_auth(OSS_ID, OSS_SECRET, OSS_AUTH_VERSION), endpoint, bucket_name) bucket.create_bucket() @@ -106,7 +106,7 @@ def test_restore_object_with_wrong_request(self): from oss2.models import RestoreJobParameters, RestoreConfiguration endpoint = OSS_ENDPOINT - bucket_name = OSS_BUCKET + "-test-restore-2" + bucket_name = self.OSS_BUCKET + "-test-restore-2" bucket = oss2.Bucket(oss2.make_auth(OSS_ID, OSS_SECRET, OSS_AUTH_VERSION), endpoint, bucket_name) bucket.create_bucket() @@ -124,7 +124,7 @@ def test_restore_archive_object_with_job_parameters(self): from oss2.models import RestoreJobParameters, RestoreConfiguration, RESTORE_TIER_BULK endpoint = OSS_ENDPOINT - bucket_name = OSS_BUCKET + "-test-restore-3" + bucket_name = self.OSS_BUCKET + "-test-restore-3" bucket = oss2.Bucket(oss2.make_auth(OSS_ID, OSS_SECRET, OSS_AUTH_VERSION), endpoint, bucket_name) bucket.create_bucket() @@ -267,7 +267,7 @@ def progress_callback(bytes_consumed, total_bytes): def test_request_error(self): bad_endpoint = random_string(8) + '.' + random_string(16) + '.com' - bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), bad_endpoint, OSS_BUCKET) + bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), bad_endpoint, self.OSS_BUCKET) try: bucket.get_bucket_acl() @@ -281,13 +281,13 @@ def test_request_error(self): self.assertTrue(e.body) def test_timeout(self): - bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), OSS_ENDPOINT, OSS_BUCKET, + bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), OSS_ENDPOINT, self.OSS_BUCKET, connect_timeout=0.001) self.assertRaises(RequestError, bucket.get_bucket_acl) def test_default_timeout(self): oss2.defaults.connect_timeout = 0.001 - bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), OSS_ENDPOINT, OSS_BUCKET) + bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), OSS_ENDPOINT, self.OSS_BUCKET) self.assertRaises(RequestError, bucket.get_bucket_acl) oss2.defaults.connect_timeout = 60 @@ -330,7 +330,7 @@ def test_anonymous(self): self.bucket.put_bucket_acl('public-read-write') wait_meta_sync() - b = oss2.Bucket(oss2.AnonymousAuth(), OSS_ENDPOINT, OSS_BUCKET) + b = oss2.Bucket(oss2.AnonymousAuth(), OSS_ENDPOINT, self.OSS_BUCKET) b.put_object(key, content) result = b.get_object(key) self.assertEqual(result.read(), content) @@ -724,7 +724,7 @@ def test_object_exists(self): key = self.random_key() auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-object-exists" + bucket_name = self.OSS_BUCKET + "-test-object-exists" bucket = oss2.Bucket(auth, OSS_ENDPOINT, bucket_name) self.assertRaises(NoSuchBucket, bucket.object_exists, key) @@ -749,7 +749,7 @@ def test_get_object_meta(self): # bucket no exist auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-get-object-meta" + bucket_name = self.OSS_BUCKET + "-test-get-object-meta" bucket = oss2.Bucket(auth, OSS_ENDPOINT, bucket_name) self.assertRaises(NoSuchBucket, bucket.get_object_meta, key) @@ -868,7 +868,7 @@ def test_disable_crc(self): key = self.random_key('.txt') content = random_bytes(1024 * 100) - bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), OSS_ENDPOINT, OSS_BUCKET, enable_crc=False) + bucket = oss2.Bucket(oss2.Auth(OSS_ID, OSS_SECRET), OSS_ENDPOINT, self.OSS_BUCKET, enable_crc=False) # put put_result = bucket.put_object(key, content) @@ -949,7 +949,7 @@ def test_get_symlink(self): # bucket no exist auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-get-symlink" + bucket_name = self.OSS_BUCKET + "-test-get-symlink" bucket = oss2.Bucket(auth, OSS_ENDPOINT, bucket_name) self.assertRaises(NoSuchBucket, bucket.get_symlink, symlink) diff --git a/tests/test_object_request_payment.py b/tests/test_object_request_payment.py index af72a884..d9762488 100644 --- a/tests/test_object_request_payment.py +++ b/tests/test_object_request_payment.py @@ -19,7 +19,7 @@ def setUp(self): policy_text += '"Action":["oss:*"],' policy_text += '"Effect":"Allow",' policy_text += '"Principal":["{0}"],'.format(OSS_PAYER_UID) - policy_text += '"Resource": ["acs:oss:*:*:{0}","acs:oss:*:*:{0}/*"]'.format(OSS_BUCKET) + policy_text += '"Resource": ["acs:oss:*:*:{0}","acs:oss:*:*:{0}/*"]'.format(self.OSS_BUCKET) policy_text += '}]}' self.bucket.put_bucket_policy(policy_text) @@ -27,7 +27,7 @@ def setUp(self): result = self.bucket.put_bucket_request_payment(PAYER_REQUESTER) self.assertEqual(result.status, 200) - self.payer_bucket = oss2.Bucket(oss2.Auth(OSS_PAYER_ID, OSS_PAYER_SECRET), OSS_ENDPOINT, OSS_BUCKET) + self.payer_bucket = oss2.Bucket(oss2.Auth(OSS_PAYER_ID, OSS_PAYER_SECRET), OSS_ENDPOINT, self.OSS_BUCKET) def test_put_object(self): key = 'requestpayment-test-put-object' diff --git a/tests/test_object_request_payment_versions.py b/tests/test_object_request_payment_versions.py index ff33d0d9..18ef025e 100644 --- a/tests/test_object_request_payment_versions.py +++ b/tests/test_object_request_payment_versions.py @@ -13,7 +13,7 @@ class TestObjectRequestPaymentVersions(OssTestCase): def setUp(self): OssTestCase.setUp(self) self.endpoint = OSS_ENDPOINT - bucket_name = OSS_BUCKET + "-test-request-payment-versionging" + bucket_name = self.OSS_BUCKET + "-test-request-payment-versionging" policy_text = '' policy_text += '{' diff --git a/tests/test_object_versioning.py b/tests/test_object_versioning.py index e59c95d2..d1d4030e 100644 --- a/tests/test_object_versioning.py +++ b/tests/test_object_versioning.py @@ -20,7 +20,7 @@ def test_resumable_download_with_version(self): from oss2.models import BatchDeleteObjectVersionList auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-resumable-download-with-version" + bucket_name = self.OSS_BUCKET + "-test-resumable-download-with-version" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -73,7 +73,7 @@ def test_multipart_with_versionging(self): from oss2.utils import calc_obj_crc_from_parts auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-multipart-with-versionging" + bucket_name = self.OSS_BUCKET + "-test-multipart-with-versionging" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -127,7 +127,7 @@ def test_upload_part_copy_with_versioning(self): from oss2.models import BatchDeleteObjectVersionList auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-upload-part-copy-with-versioning" + bucket_name = self.OSS_BUCKET + "-test-upload-part-copy-with-versioning" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -202,7 +202,7 @@ def test_put_symlink_with_version(self): from oss2.models import BucketVersioningConfig auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-put-symlink-with-version" + bucket_name = self.OSS_BUCKET + "-test-put-symlink-with-version" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -269,7 +269,7 @@ def test_put_object_tagging_with_versioning(self): from oss2.models import Tagging auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-put-object-tagging-version" + bucket_name = self.OSS_BUCKET + "-test-put-object-tagging-version" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -377,7 +377,7 @@ def test_batch_delete_same_object_multi_version(self): from oss2.models import BatchDeleteObjectVersionList auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-batch-delete-version" + bucket_name = self.OSS_BUCKET + "-test-batch-delete-version" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -437,7 +437,7 @@ def test_batch_delete_objects_multi_version(self): from oss2.models import BatchDeleteObjectVersionList auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-batch-delete-objects-version" + bucket_name = self.OSS_BUCKET + "-test-batch-delete-objects-version" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -538,7 +538,7 @@ def test_get_object_meta_with_version(self): from oss2.models import BatchDeleteObjectVersionList auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-get-object-meta-version" + bucket_name = self.OSS_BUCKET + "-test-get-object-meta-version" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -610,7 +610,7 @@ def test_object_acl_with_version(self): from oss2.models import BatchDeleteObjectVersionList auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-object-acl-version" + bucket_name = self.OSS_BUCKET + "-test-object-acl-version" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -707,7 +707,7 @@ def test_head_object_with_version(self): from oss2.models import BatchDeleteObjectVersionList auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-head-object-version" + bucket_name = self.OSS_BUCKET + "-test-head-object-version" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -822,7 +822,7 @@ def test_copy_object_with_version(self): from oss2.models import BatchDeleteObjectVersionList auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-copy-object-version" + bucket_name = self.OSS_BUCKET + "-test-copy-object-version" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -902,7 +902,7 @@ def test_delete_object_with_version(self): from oss2.models import BatchDeleteObjectVersionList auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-delete-object-version" + bucket_name = self.OSS_BUCKET + "-test-delete-object-version" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -970,7 +970,7 @@ def test_restore_object_with_version(self): from oss2.models import BucketVersioningConfig auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-restore-object-version" + bucket_name = self.OSS_BUCKET + "-test-restore-object-version" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE, oss2.models.BucketCreateConfig(oss2.BUCKET_STORAGE_CLASS_ARCHIVE)) @@ -1008,7 +1008,7 @@ def test_delete_object_versions_with_invalid_arguments(self): from oss2.models import BatchDeleteObjectVersionList auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-delete-object-versions" + bucket_name = self.OSS_BUCKET + "-test-delete-object-versions" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -1030,7 +1030,7 @@ def test_update_metadata_versioning(self): object_name = "test-object" # test normal bucket auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-update-metadata" + bucket_name = self.OSS_BUCKET + "-test-update-metadata" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) @@ -1052,7 +1052,7 @@ def test_update_metadata_versioning(self): # test versioning bucket from oss2.models import BucketVersioningConfig auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-update-metadata-version" + bucket_name = self.OSS_BUCKET + "-test-update-metadata-version" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE) wait_meta_sync() diff --git a/tests/test_proxy.py b/tests/test_proxy.py index 15ca9f25..7f4ffea5 100644 --- a/tests/test_proxy.py +++ b/tests/test_proxy.py @@ -7,7 +7,7 @@ class TestProxy(OssTestCase): def test_with_proxy(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-proxy" + bucket_name = self.OSS_BUCKET + "-test-proxy" proxies = {'http': 'http://localhost:8888'} diff --git a/tests/test_server_side_encryotion.py b/tests/test_server_side_encryotion.py index c42cfa65..58d173f3 100644 --- a/tests/test_server_side_encryotion.py +++ b/tests/test_server_side_encryotion.py @@ -16,7 +16,7 @@ def setUp(self): def test_put_bucket_encryption(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-put-bucket-encryption" + bucket_name = self.OSS_BUCKET + "-test-put-bucket-encryption" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket() @@ -122,7 +122,7 @@ def inner_put_object_with_encryption(self, bucket, object_name, data, sse_algori def test_put_object_with_encryption(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-put-object-data-encryption" + bucket_name = self.OSS_BUCKET + "-test-put-object-data-encryption" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket() @@ -190,7 +190,7 @@ def inner_append_object_with_encryption(self, bucket, object_name, position, dat def test_append_object_with_encryption(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-append-object-data-encryption" + bucket_name = self.OSS_BUCKET + "-test-append-object-data-encryption" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket() @@ -218,7 +218,7 @@ def test_append_object_with_encryption(self): def test_multipart_upload(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-multipart-upload-data-encryption" + bucket_name = self.OSS_BUCKET + "-test-multipart-upload-data-encryption" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket() @@ -296,7 +296,7 @@ def test_multipart_upload(self): def test_resumable_uoload(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-resumable-upload-data-encryption" + bucket_name = self.OSS_BUCKET + "-test-resumable-upload-data-encryption" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket() @@ -342,7 +342,7 @@ def test_resumable_uoload(self): def test_copy_object(self): auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-copy-object-data-encryption" + bucket_name = self.OSS_BUCKET + "-test-copy-object-data-encryption" bucket = oss2.Bucket(auth, self.endpoint, bucket_name) bucket.create_bucket() diff --git a/tests/test_sts.py b/tests/test_sts.py index bb8025f9..cb9b7feb 100644 --- a/tests/test_sts.py +++ b/tests/test_sts.py @@ -70,7 +70,7 @@ def init_bucket(self): self.token = fetch_sts_token(OSS_STS_ID, OSS_STS_KEY, OSS_STS_ARN) auth = oss2.StsAuth(self.token.access_key_id, self.token.access_key_secret, self.token.security_token) - self.bucket = oss2.Bucket(auth, OSS_ENDPOINT, OSS_BUCKET) + self.bucket = oss2.Bucket(auth, OSS_ENDPOINT, self.OSS_BUCKET) self.bucket.create_bucket() def test_object(self): diff --git a/tests/test_upload.py b/tests/test_upload.py index e2da6637..a637d536 100644 --- a/tests/test_upload.py +++ b/tests/test_upload.py @@ -342,7 +342,7 @@ def test_upload_large_with_tagging(self): def test_upload_sequenial(self): endpoint = "http://oss-cn-shanghai.aliyuncs.com" auth = oss2.Auth(OSS_ID, OSS_SECRET) - bucket_name = OSS_BUCKET + "-test-upload-sequential" + bucket_name = self.OSS_BUCKET + "-test-upload-sequential" bucket = oss2.Bucket(auth, endpoint, bucket_name) bucket.create_bucket()