def test_defaults(monkeypatch, tmp_path): monkeypatch.setattr( 'satellite.config.DEFAULT_CONFIG_PATH', tmp_path / 'config.yml', ) config = configure() assert dataclasses.asdict(config) == DEFAULT_CONFIG_VALUES
def main(**kwargs): set_start_method('fork') # PyInstaller supports only fork start method pickling_support.install() init_satellite_dir() try: config = configure(**{ name: value for name, value in kwargs.items() if value is not None }) except InvalidConfigError as exc: raise click.ClickException(f'Invalid config: {exc}') from exc satellite_logging.configure(log_path=config.log_path, silent=config.silent) db.configure(config.db_path) try: db.init() except db.DBVersionMismatch as exc: raise click.ClickException(exc) from exc deleted_aliases = AliasStore.cleanup() logger = logging.getLogger() logger.info(f'Deleted {deleted_aliases} expired aliases.') app = WebApplication(config) app.start()
def test_from_default_config_file(monkeypatch, tmp_path): config_path = tmp_path / 'config.yml' _write_config(config_path, web_server_port=1) monkeypatch.setattr('satellite.config.DEFAULT_CONFIG_PATH', config_path) config = configure() assert dataclasses.asdict(config) == { **DEFAULT_CONFIG_VALUES, 'web_server_port': 1, }
def main(**kwargs): set_start_method('fork') # PyInstaller supports only fork start method pickling_support.install() init_satellite_dir() try: config = configure(**{ name: value for name, value in kwargs.items() if value is not None }) except InvalidConfigError as exc: raise click.ClickException(f'Invalid config: {exc}') from exc logging.configure(log_path=config.log_path, silent=config.silent) db.configure(config.db_path) db.init() app = WebApplication(config) app.start()
def main(**kwargs): set_start_method('fork') # PyInstaller supports only fork start method pickling_support.install() init_satellite_dir() try: config = configure(**{ name: value for name, value in kwargs.items() if value is not None }) except InvalidConfigError as exc: raise click.ClickException(f'Invalid config: {exc}') from exc satellite_logging.configure(log_path=config.log_path, silent=config.silent) logger = logging.getLogger() db.configure(config.db_path) try: db.init() except db.DBVersionMismatch as exc: raise click.ClickException(exc) from exc if config.routes_path: with open(config.routes_path, 'r') as stream: try: loaded_routes_count = load_from_yaml(stream) except LoadError as exc: raise click.ClickException( f'Unable to load routes from file: {exc}') from exc logger.info( f'Loaded {loaded_routes_count} routes from routes config file.') deleted_aliases = AliasStore.cleanup() logger.info(f'Deleted {deleted_aliases} expired aliases.') app = WebApplication(config) app.start()
def test_invalid_config_args(monkeypatch, tmp_path): config_path = tmp_path / 'config.yml' monkeypatch.setattr('satellite.config.DEFAULT_CONFIG_PATH', config_path) with pytest.raises(InvalidConfigError): configure(web_server_port='invalid')
def test_invalid_config_syntax(monkeypatch, tmp_path): config_path = tmp_path / 'config.yml' _write_config(config_path, raw_data='{invalid') monkeypatch.setattr('satellite.config.DEFAULT_CONFIG_PATH', config_path) with pytest.raises(InvalidConfigError): configure()