def main(): s3_resource = boto3.resource('s3') s3_client = boto3.client('s3') print( 2 * '\n') print('s3_clent object:') print(s3_client) print() test_bucket= 'jhsu-s3-boto3-bucket1' test_file = 'jhsu-s3-boto3-file1' s3_bucket_list = [] s3.s3_list_buckets(s3_client) print() s3_bucket_url = s3.s3_create_bucket(s3_client, test_bucket) print(s3_bucket_url) print() (s3_bucket_list, s3_bucket_count) = s3_bucket_list = s3.s3_list_buckets(s3_client) print() s3_bucket_deleted = s3.s3_delete_bucket(s3_client, test_bucket) print(type(s3_bucket_deleted)) print() s3.s3_list_buckets(s3_client) print() return
def test_mock_delete_bucket(): s3_pass_pattern = 's3_delete_bucket_passed' s3_delete_bucket_response = s3.s3_delete_bucket(s3_client, test_bucket) print() print(s3_delete_bucket_response) final_s3_pass_pattern = s3_pass_pattern + '_' + str( s3_delete_bucket_response) print() print(final_s3_pass_pattern) assert final_s3_pass_pattern == s3_pass_pattern + '_None'
def test_mock_delete_bucket(): s3_client = boto3.client('s3') s3_create_bucket_response = s3.s3_create_bucket(s3_client, test_bucket) s3_delete_bucket_response = s3.s3_delete_bucket(s3_client, test_bucket) print(s3_delete_bucket_response) assert s3_delete_bucket_response['HTTPStatusCode'] == 204
print("--- S3 bucket list ---") (s3_bucket_list, s3_bucket_cnt) = s3.s3_list_buckets(s3_client) util.s3_print_bucket_list(s3_bucket_list) print("--- S3 create bucket ---") s3_create_bucket_response = s3.s3_create_bucket(s3_client, test_bucket) print("--- Validate bucket creation ---") if s3.s3_check_bucket_in_list(s3_client, test_bucket): print(" Bucket creation passed! ") else: print(" Bucket creation failed! ") print("--- S3 bucket list ---") (s3_bucket_list, s3_bucket_cnt) = s3.s3_list_buckets(s3_client) util.s3_print_bucket_list(s3_bucket_list) print("--- S3 delete bucket ---") s3_delete_bucket_response = s3.s3_delete_bucket(s3_client, test_bucket) print("--- Validate bucket deletion ---") if s3.s3_check_bucket_in_list(s3_client, test_bucket): print(" Bucket deletion failed! ") else: print(" Bucket deletion passed! ") print("--- S3 bucket list ---") (s3_bucket_list, s3_bucket_cnt) = s3.s3_list_buckets(s3_client) util.s3_print_bucket_list(s3_bucket_list)