def test__create_or_update_bucket_create_bucket_service_error(object_storage_client, get_existing_bucket_patch): get_existing_bucket_patch.return_value = None error_message = 'Namespace does not exist.' object_storage_client.create_bucket.side_effect = ServiceError( 400, 'NoNameSpaceExists', dict(), error_message) module = get_module() try: oci_bucket.create_or_update_bucket(object_storage_client, module) except Exception as ex: assert error_message in ex.args[0]
def test_create_or_update_bucket_update_bucket_service_error( object_storage_client, get_existing_bucket_patch): get_existing_bucket_patch.return_value = oci.object_storage.models.Bucket() error_message = "Namespace does not exist." object_storage_client.update_bucket.side_effect = ServiceError( 400, "NoNameSpaceExists", dict(), error_message) object_storage_client.get_bucket.return_value = Bucket() module = get_module() try: oci_bucket.create_or_update_bucket(object_storage_client, module) except Exception as ex: assert error_message in ex.args[0]
def test_create_or_update_bucket_no_update(object_storage_client, get_existing_bucket_patch): existing_bucket = oci.object_storage.models.Bucket() existing_bucket.name = 'testbucket' existing_bucket.metadata = {'org': 'oracle'} existing_bucket.public_access_type = 'NoPublicAccess' get_existing_bucket_patch.return_value = existing_bucket result = oci_bucket.create_or_update_bucket( object_storage_client, get_module()) assert result['changed'] is False
def test_create_or_update_bucket_no_update(object_storage_client, get_existing_bucket_patch): existing_bucket = oci.object_storage.models.Bucket() existing_bucket.name = "testbucket" existing_bucket.metadata = {"org": "oracle"} existing_bucket.public_access_type = "NoPublicAccess" get_existing_bucket_patch.return_value = existing_bucket result = oci_bucket.create_or_update_bucket(object_storage_client, get_module()) assert result["changed"] is False
def test_create_or_update_bucket_create_success(object_storage_client, get_existing_bucket_patch): get_existing_bucket_patch.return_value = None bucket = oci.object_storage.models.Bucket() bucket.name = 'myBucket' object_storage_client.create_bucket.return_value = get_response( 200, None, bucket, None) result = oci_bucket.create_or_update_bucket( object_storage_client, get_module()) bucket = result['bucket'] assert 'myBucket' in bucket['name']
def test_create_or_update_bucket_update_success(object_storage_client, get_existing_bucket_patch): existing_bucket = oci.object_storage.models.Bucket() existing_bucket.name = 'myBucket' existing_bucket.metadata = {'project': 'test_project'} get_existing_bucket_patch.return_value = existing_bucket updated_bucket = oci.object_storage.models.Bucket() updated_bucket.name = 'myBucket' updated_bucket.metadata = {'project': 'prod_project'} object_storage_client.update_bucket.return_value = get_response( 200, None, updated_bucket, None) result = oci_bucket.create_or_update_bucket( object_storage_client, get_module()) bucket = result['bucket'] assert 'prod_project' in bucket['metadata']['project']
def test_create_or_update_bucket_update_success(object_storage_client, get_existing_bucket_patch): existing_bucket = oci.object_storage.models.Bucket() existing_bucket.name = "myBucket" existing_bucket.metadata = {"project": "test_project"} get_existing_bucket_patch.return_value = existing_bucket updated_bucket = oci.object_storage.models.Bucket() updated_bucket.name = "myBucket" updated_bucket.metadata = {"project": "prod_project"} object_storage_client.update_bucket.return_value = get_response( 200, None, updated_bucket, None) result = oci_bucket.create_or_update_bucket(object_storage_client, get_module()) bucket = result["bucket"] assert "prod_project" in bucket["metadata"]["project"]