def test_config_env_vars(self): os.environ['REDIS_HOST'] = "testhost.example.com" cli_config = CliConfig() self.assertEqual( cli_config.connection.connection_pool.connection_kwargs['host'], 'testhost.example.com', )
def test_config_file_option(self): """""" cli_config = CliConfig(config='tests.config_files.dummy') self.assertEqual( cli_config.connection.connection_pool.connection_kwargs['host'], 'testhost.example.com', ) runner = CliRunner() result = runner.invoke(main, ['info', '--config', cli_config.config]) self.assertEqual(result.exit_code, 1)
def test_config_file_default_options_override(self): """""" cli_config = CliConfig(config='tests.config_files.dummy_override') self.assertEqual( cli_config.connection.connection_pool.connection_kwargs['host'], 'testhost.example.com', ) self.assertEqual( cli_config.connection.connection_pool.connection_kwargs['port'], 6378) self.assertEqual( cli_config.connection.connection_pool.connection_kwargs['db'], 2) self.assertEqual( cli_config.connection.connection_pool. connection_kwargs['password'], '123')
def test_config_file_default_options(self): """""" cli_config = CliConfig(config='tests.config_files.dummy') self.assertEqual( cli_config.connection.connection_pool.connection_kwargs['host'], 'testhost.example.com', ) self.assertEqual( cli_config.connection.connection_pool.connection_kwargs['port'], 6379) self.assertEqual( cli_config.connection.connection_pool.connection_kwargs['db'], 0) self.assertEqual( cli_config.connection.connection_pool. connection_kwargs['password'], None)
def wrapper(*args, **kwargs): ctx = click.get_current_context() cli_config = CliConfig(**kwargs) return ctx.invoke(func, cli_config, *args[1:], **kwargs)