import os

import pytest

from modelkit.assets import errors
from tests.conftest import skip_unless


def _perform_driver_error_object_not_found(driver):
    with pytest.raises(errors.ObjectDoesNotExistError):
        driver.download_object("someasset", "somedestination")
    assert not os.path.isfile("somedestination")


def test_local_driver(local_assetsmanager):
    local_driver = local_assetsmanager.remote_assets_store.driver
    _perform_driver_error_object_not_found(local_driver)


@skip_unless("ENABLE_GCS_TEST", "True")
def test_gcs_driver(gcs_assetsmanager):
    gcs_driver = gcs_assetsmanager.remote_assets_store.driver
    _perform_driver_error_object_not_found(gcs_driver)


@skip_unless("ENABLE_S3_TEST", "True")
def test_s3_driver(s3_assetsmanager):
    s3_driver = s3_assetsmanager.remote_assets_store.driver
    _perform_driver_error_object_not_found(s3_driver)

[(20, 'tests.conftest.skip_unless', 'skip_unless', False, 'from tests.conftest import skip_unless\n'), (26, 'tests.conftest.skip_unless', 'skip_unless', False, 'from tests.conftest import skip_unless\n'), (10, 'pytest.raises', 'pytest.raises', False, 'import pytest\n'), (12, 'os.path.isfile', 'os.path.isfile', False, 'import os\n')]