コード例 #1
0
ファイル: test_cache.py プロジェクト: 3liz/py-qgis-server
def test_postgres_pgservice_fail() -> None:
 
    url = 'postgres:///?service=not_working&project=france_parts'

    cacheservice = QgsCacheManager()

    with pytest.raises(FileNotFoundError):
        cacheservice.lookup(url)
コード例 #2
0
ファイル: test_cache.py プロジェクト: 3liz/py-qgis-server
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
コード例 #3
0
ファイル: test_cache.py プロジェクト: 3liz/py-qgis-server
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
コード例 #4
0
ファイル: test_cache.py プロジェクト: 3liz/py-qgis-server
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
コード例 #5
0
ファイル: test_cache.py プロジェクト: 3liz/py-qgis-server
def test_invalid_scheme() -> None:
    """ Test non existant file return error
    """
    cacheservice = QgsCacheManager()
    with pytest.raises(FileNotFoundError):    
        cacheservice.lookup('badscheme:///foo')
コード例 #6
0
ファイル: test_cache.py プロジェクト: 3liz/py-qgis-server
def test_file_not_found() -> None:
    """ Test non existant file return error
    """
    cacheservice = QgsCacheManager()
    with pytest.raises(FileNotFoundError):    
        cacheservice.lookup('I_do_not_exists')