Exemple #1
0
def test_preload_projects(data) -> None:
    """ Test preloading projects files
    """
    cacheservice = QgsCacheManager()
    path = data / 'preloads.list'

    loaded = preload_projects_file(path, cacheservice)
    assert loaded == 2

    # file:france_parts.qgs
    # project_simple.qgs
    # raster_layer.qgs (invalid layer)

    # Ensure  that items are in static cache
    items = list(k for k,_ in cacheservice.items(CacheType.STATIC))
    assert "file:france_parts.qgs" in items
    assert "project_simple.qgs" in items

    details = cacheservice.peek('file:france_parts.qgs')
    assert details is not None

    details = cacheservice.peek('project_simple.qgs')
    assert details is not None

    details = cacheservice.peek('raster_layer.qgs')
    assert details is None
Exemple #2
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
Exemple #3
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
Exemple #4
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 project is not None

    details = cacheservice.peek(url)
    assert details is not None
    assert details.project is project
Exemple #5
0
def test_preload_projects(data) -> None:
    """ Test preloading projects files
    """
    cacheservice = QgsCacheManager()
    path = data / 'preloads.list'

    loaded = preload_projects_file(path, cacheservice)
    assert loaded == 2

    # file:france_parts.qgs
    # project_simple.qgs
    # raster_layer.qgs (invalid layer)

    details = cacheservice.peek('file:france_parts.qgs')
    assert details is not None

    details = cacheservice.peek('project_simple.qgs')
    assert details is not None

    details = cacheservice.peek('raster_layer.qgs')
    assert details is None
Exemple #6
0
def test_get_modified_time(data) -> None:
    """ Test modified time
    """
    cacheservice = QgsCacheManager()

    path = data / 'france_parts.qgs'
    modified_time1 = cacheservice.get_modified_time('file:france_parts.qgs')
    
    # Check that no files is loaded
    assert cacheservice.peek('file:france_parts.qgs') is None

    # Update file
    path.touch()
    modified_time2 = cacheservice.get_modified_time('file:france_parts.qgs')

    assert modified_time2 > modified_time1