コード例 #1
0
    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',
        )
コード例 #2
0
 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)
コード例 #3
0
    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')
コード例 #4
0
    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)
コード例 #5
0
 def wrapper(*args, **kwargs):
     ctx = click.get_current_context()
     cli_config = CliConfig(**kwargs)
     return ctx.invoke(func, cli_config, *args[1:], **kwargs)