Ejemplo n.º 1
0
def test_aliases() -> None:
    """ Test alias resolution for file
    """
    rootpath = Path(confservice.get('projects.cache','rootdir'))

    cacheservice = QgsCacheManager()

    url = cacheservice.resolve_alias('france_parts')
    assert url.scheme == 'file'
    assert url.path   == str(rootpath / 'france_parts')
    
    url = cacheservice.resolve_alias('file:france_parts')
    assert url.scheme == 'file'
    assert url.path   == str(rootpath / 'france_parts')

    url = cacheservice.resolve_alias('foo:france_parts')
    assert url.scheme == 'file'
    assert url.path   == '/foobar/france_parts'

    url = cacheservice.resolve_alias('test:france_parts')
    assert url.scheme == ''
    assert url.path   == str(rootpath / 'france_parts')

    url = cacheservice.resolve_alias('bar:france_parts')
    assert url.scheme == 'file'
    assert url.path   == 'foobar'
    assert url.query  == 'data=france_parts'
Ejemplo n.º 2
0
def test_absolute_path_with_alias() -> None:
    """
    """
    cacheservice = QgsCacheManager()

    # Passing an absolute path that is compatible with
    # the scheme base url is ok
    url = cacheservice.resolve_alias('foo:/foobar/france_parts')
    assert url.scheme == 'file'
    assert url.path   == '/foobar/france_parts'

    # But not a path wich does is no a relative path
    # to base url
    with pytest.raises(PathNotAllowedError):
        url = cacheservice.resolve_alias('foo:/france_parts')