def test_argument_precedence(): """ Test argument precedences From lowest to highest: - default - environment - config file - command line """ args = read_configuration([ '--workers', '3', '--port', '9090', '--config', 'test.conf', ]) conf = confservice['server'] # Workers must be 3 assert args.workers == 3 assert conf.getint('workers') == 3 # Port must be 9090 assert args.port == 9090 assert conf.getint('port') == 9090 # rootdir must be '/tmp/' defined in config file assert confservice.get('projects.cache', 'rootdir') == '/tmp/'
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'
def init() -> None: """ """ LOGGER.debug("*** Initializing ban observer") confservice.add_section('cache.observers:ban') global server_address, http_client server_address = confservice.get('cache.observers:ban', 'server_address') http_client = AsyncHTTPClient() LOGGER.debug("*** Ban observer: sending_request to %s", server_address)
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