예제 #1
0
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)
예제 #2
0
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()))
예제 #3
0
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)
예제 #4
0
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()))
예제 #5
0
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')
예제 #6
0
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
예제 #7
0
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
예제 #8
0
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')
예제 #9
0
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')
예제 #10
0
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()))
예제 #11
0
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'
예제 #12
0
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'
예제 #13
0
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')
예제 #14
0
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'
예제 #15
0
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')
예제 #16
0
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')
예제 #17
0
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()))
예제 #18
0
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')
예제 #19
0
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'
예제 #20
0
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')