Beispiel #1
0
def test_postgres_pgservice_fail() -> None:
 
    url = 'postgres:///?service=not_working&project=france_parts'

    cacheservice = QgsCacheManager()

    with pytest.raises(FileNotFoundError):
        cacheservice.lookup(url)
Beispiel #2
0
def test_postgres_cache() -> None:
    """ Test postgres handler
    """
    cacheservice = QgsCacheManager()

    url = 'postgres:///?project=france_parts'

    details = cacheservice.peek(url)
    assert details is None

    project, updated = cacheservice.lookup(url)
    assert updated
    assert isinstance(project,QgsProject)

    # Check that project is updated
    project, updated = cacheservice.lookup(url)
    assert not updated
    assert isinstance(project,QgsProject)

    details = cacheservice.peek(url)
    assert details is not None
    assert details.project is project
Beispiel #3
0
def test_postgres_with_pgservice() -> None:
 
    url = 'postgres:///?service=local&project=france_parts'

    cacheservice = QgsCacheManager()

    details = cacheservice.peek(url)
    assert details is None

    project, updated = cacheservice.lookup(url)
    assert updated
    assert isinstance(project,QgsProject)

    details = cacheservice.peek(url)
    assert details is not None
    assert details.project is project
Beispiel #4
0
def test_projects_scheme() -> None:
    """ Tetst file protocol handler
    """
    rootpath = Path(confservice.get('projects.cache','rootdir'))

    cacheservice = QgsCacheManager()
    details = cacheservice.peek('test:france_parts')
    assert details is None

    project, updated = cacheservice.lookup('test:france_parts')
    assert updated
    assert project is not None
    assert project.fileName() == str(rootpath / 'france_parts.qgs')

    details = cacheservice.peek('test:france_parts')
    assert details is not None
    assert details.project is project
Beispiel #5
0
def test_invalid_scheme() -> None:
    """ Test non existant file return error
    """
    cacheservice = QgsCacheManager()
    with pytest.raises(FileNotFoundError):    
        cacheservice.lookup('badscheme:///foo')
Beispiel #6
0
def test_file_not_found() -> None:
    """ Test non existant file return error
    """
    cacheservice = QgsCacheManager()
    with pytest.raises(FileNotFoundError):    
        cacheservice.lookup('I_do_not_exists')