def test_file_in_handler_with_vfs_error(): """vfs file path is expanded""" uri = 'zip://tests/data/files.zip!/inputs/RGB.byte.tif' ctx = MockContext() with pytest.raises(click.BadParameter) as e: file_in_handler(ctx, 'INPUT', uri) assert uri in str(e) and 'is not valid' in str(e)
def test_file_in_handler_with_vfs_nonexistent(): """archive does not exist""" ctx = MockContext() with pytest.raises(click.BadParameter): file_in_handler( ctx, 'INPUT', 'zip://{0}/files.zip!/inputs/RGB.byte.tif'.format( uuid.uuid4()))
def test_file_in_handler_with_vfs_nonexistent(): """archive does not exist""" ctx = MockContext() with pytest.raises(click.BadParameter): file_in_handler( ctx, 'INPUT', 'zip://{0}/files.zip!/inputs/RGB.byte.tif'.format(uuid.uuid4()))
def test_file_in_handler_with_vfs(): """vfs file path path is expanded""" ctx = MockContext() retval = file_in_handler( ctx, 'INPUT', 'zip://tests/data/files.zip!/inputs/RGB.byte.tif') assert retval.startswith('zip:///') assert retval.endswith('tests/data/files.zip!/inputs/RGB.byte.tif')
def test_file_in_handler_with_vfs(): """vfs file path is expanded""" uri = 'zip://tests/data/files.zip!/RGB.byte.tif' ctx = MockContext() retval = file_in_handler(ctx, 'INPUT', uri) assert retval.startswith('zip://') assert 'tests/data/files.zip!/RGB.byte.tif' in retval
def test_file_in_handler_with_vfs(): """vfs file path is expanded""" uri = 'zip://tests/data/files.zip!/RGB.byte.tif' ctx = MockContext() retval = file_in_handler(ctx, 'INPUT', uri) assert retval.startswith('zip:///') assert 'tests/data/files.zip!/RGB.byte.tif' in retval
def test_file_in_handler_bad_scheme(): """lolwut scheme is not supported""" ctx = MockContext() with pytest.raises(click.BadParameter): _ = file_in_handler(ctx, 'INPUT', 'lolwut://bogus')
def test_file_in_handler_no_vfs(): """file path is expanded to abspath""" from rasterio.rio.options import abspath_forward_slashes ctx = MockContext() retval = file_in_handler(ctx, 'INPUT', 'tests/data/RGB.byte.tif') assert retval == abspath_forward_slashes('tests/data/RGB.byte.tif')
def test_file_in_handler_no_vfs_nonexistent(): """file does not exist""" ctx = MockContext() with pytest.raises(click.BadParameter): file_in_handler(ctx, 'INPUT', '{0}.tif'.format(uuid.uuid4()))
def test_file_in_handler_vsi(): """Legacy GDAL filenames are handled""" ctx = MockContext() retval = file_in_handler(ctx, 'INPUT', '/vsifoo/bar.tif') assert retval == '/vsifoo/bar.tif'
def test_file_in_handler_with_vfs_file(): """vfs file path path is expanded""" ctx = MockContext() retval = file_in_handler(ctx, 'INPUT', 'file://tests/data/RGB.byte.tif') assert retval.endswith('tests/data/RGB.byte.tif')
def test_file_in_handler_s3(): """HTTP(S) URLs are handled""" ctx = MockContext() retval = file_in_handler(ctx, 'INPUT', 's3://example.com/RGB.byte.tif') assert retval == 's3://example.com/RGB.byte.tif'
def test_file_in_handler_with_vfs_file(): """vfs file path is expanded""" ctx = MockContext() retval = file_in_handler(ctx, 'INPUT', 'file://tests/data/RGB.byte.tif') assert retval.endswith('tests/data/RGB.byte.tif')
def test_file_in_handler_no_vfs(): """file path is expanded to abspath""" ctx = MockContext() retval = file_in_handler(ctx, 'INPUT', 'tests/data/RGB.byte.tif') assert retval == os.path.abspath('tests/data/RGB.byte.tif')
def test_file_in_handler_http(): """HTTP(S) URLs are handled""" ctx = MockContext() retval = file_in_handler(ctx, 'INPUT', 'https://example.com/RGB.byte.tif') assert retval == 'https://example.com/RGB.byte.tif'
def test_file_in_handler_with_vfs(): """vfs file path path is expanded""" ctx = MockContext() retval = file_in_handler(ctx, 'INPUT', 'zip://tests/data/files.zip!/inputs/RGB.byte.tif') assert retval.startswith('zip:///') assert retval.endswith('tests/data/files.zip!/inputs/RGB.byte.tif')