def mock_get_bucket(namespace_name, bucket_name):
     return Response(
         200, {},
         Bucket(namespace="test-namespace",
                compartment_id="test-compartment-id",
                name="test-bucket-name",
                storage_tier=OBJECT_STORAGE_BUCKET_TYPE_ARCHIVE),
         Request("mock.method", "mock.url"))
Example #2
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]