def test_delete_bucket_service_error(object_storage_client):
    error_message = "Bucket Exists but not deleted due to other error"
    object_storage_client.delete_bucket.side_effect = ServiceError(
        400, "OtherError", dict(), error_message)
    try:
        oci_bucket.delete_bucket(object_storage_client, get_module())
    except Exception as e:
        assert error_message in e.args[0]
Exemplo n.º 2
0
def test_delete_bucket_success(object_storage_client, get_existing_bucket_patch):
    existing_bucket = oci.object_storage.models.Bucket()
    existing_bucket.name = 'existingBucket'
    get_existing_bucket_patch.return_value = existing_bucket
    object_storage_client.delete_bucket.return_value = get_response(
        200, None, None, None)
    result = oci_bucket.delete_bucket(object_storage_client, get_module())
    assert result['changed'] is True
    assert result['bucket']['name'] is 'existingBucket'
def test_delete_bucket_success(object_storage_client,
                               get_existing_bucket_patch):
    existing_bucket = oci.object_storage.models.Bucket()
    existing_bucket.name = "existingBucket"
    get_existing_bucket_patch.return_value = existing_bucket
    object_storage_client.delete_bucket.return_value = get_response(
        200, None, None, None)
    result = oci_bucket.delete_bucket(object_storage_client, get_module())
    assert result["changed"] is True
    assert result["bucket"]["name"] is "existingBucket"
Exemplo n.º 4
0
def test_delete_bucket_success_with_force(object_storage_client, get_existing_bucket_patch, delete_all_objects_in_bucket_patch):
    module = get_module()
    module.params.update({'force': True})
    existing_bucket = oci.object_storage.models.Bucket()
    existing_bucket.name = 'existingBucket'
    get_existing_bucket_patch.return_value = existing_bucket
    object_storage_client.delete_bucket.return_value = get_response(
        200, None, None, None)
    result = oci_bucket.delete_bucket(object_storage_client, module)
    assert result['changed'] is True
    assert result['bucket']['name'] is 'existingBucket'
def test_delete_bucket_success_with_force(
    object_storage_client,
    get_existing_bucket_patch,
    delete_all_objects_in_bucket_patch,
    delete_all_pars_of_bucket_patch,
):
    module = get_module()
    module.params.update({"force": True})
    existing_bucket = oci.object_storage.models.Bucket()
    existing_bucket.name = "existingBucket"
    get_existing_bucket_patch.return_value = existing_bucket
    object_storage_client.delete_bucket.return_value = get_response(
        200, None, None, None)
    result = oci_bucket.delete_bucket(object_storage_client, module)
    assert result["changed"] is True
    assert result["bucket"]["name"] is "existingBucket"
def test_delete_bucket_no_state_changed(object_storage_client,
                                        get_existing_bucket_patch):
    get_existing_bucket_patch.return_value = None
    result = oci_bucket.delete_bucket(object_storage_client, get_module())
    assert result["changed"] is False