From 0fab93d683f7a8d6e8ad11a60095baf5e0261a5c Mon Sep 17 00:00:00 2001 From: Theo Date: Fri, 8 Sep 2017 12:21:30 +0100 Subject: [PATCH] Fixed #809 - Added tests for various cli config parameters --- tests/dummy_settings_override.py | 8 ++++++ tests/test_cli.py | 42 ++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 tests/dummy_settings_override.py diff --git a/tests/dummy_settings_override.py b/tests/dummy_settings_override.py new file mode 100644 index 0000000..3f9830f --- /dev/null +++ b/tests/dummy_settings_override.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +from __future__ import (absolute_import, division, print_function, + unicode_literals) + +REDIS_HOST = "testhost.example.com" +REDIS_PORT = 6378 +REDIS_DB = 2 +REDIS_PASSWORD = '123' diff --git a/tests/test_cli.py b/tests/test_cli.py index dc11502..c306c81 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -62,6 +62,48 @@ class TestRQCli(RQTestCase): result = runner.invoke(main, ['info', '--config', cli_config.config]) self.assertEqual(result.exit_code, 1) + def test_config_file_default_options(self): + """""" + cli_config = CliConfig(config='tests.dummy_settings') + + 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 test_config_file_default_options_override(self): + """""" + cli_config = CliConfig(config='tests.dummy_settings_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_empty_nothing(self): """rq empty -u """ runner = CliRunner()