summaryrefslogtreecommitdiff
path: root/openstackclient/tests/test_shell.py
diff options
context:
space:
mode:
authorTerryHowe <terrylhowe@gmail.com>2015-08-10 12:33:28 -0600
committerTerry Howe <terrylhowe@gmail.com>2015-08-26 10:23:53 +0000
commit85a03945f0b5da0ec5778a929e08a641f427513a (patch)
tree1c3bcb525ed420bce2a993f8244c2a3db40a5df2 /openstackclient/tests/test_shell.py
parent6c46355734f7a7278b92645e6a465b6e38096daf (diff)
downloadpython-openstackclient-85a03945f0b5da0ec5778a929e08a641f427513a.tar.gz
Create log configuration class
Configuration of logging gets triggered twice. The first time it uses the CLI options when the application is started and second it uses the configuration file after that is read. The state of the logging needs to be saved from the first to the second time, so I created a class. Implements: blueprint logging-migration Change-Id: I7b8d1a3b6fd128e98cafd7c16009c7b694a52146
Diffstat (limited to 'openstackclient/tests/test_shell.py')
-rw-r--r--openstackclient/tests/test_shell.py94
1 files changed, 4 insertions, 90 deletions
diff --git a/openstackclient/tests/test_shell.py b/openstackclient/tests/test_shell.py
index 5b844753..cacd2fb7 100644
--- a/openstackclient/tests/test_shell.py
+++ b/openstackclient/tests/test_shell.py
@@ -623,12 +623,9 @@ class TestShellCli(TestShell):
@mock.patch("os_client_config.config.OpenStackConfig._load_vendor_file")
@mock.patch("os_client_config.config.OpenStackConfig._load_config_file")
- @mock.patch("openstackclient.common.context._setup_handler_for_logging")
- def test_shell_args_cloud_public(self, setup_handler, config_mock,
- public_mock):
+ def test_shell_args_cloud_public(self, config_mock, public_mock):
config_mock.return_value = ('file.yaml', copy.deepcopy(CLOUD_2))
public_mock.return_value = ('file.yaml', copy.deepcopy(PUBLIC_1))
- setup_handler.return_value = mock.MagicMock()
_shell = make_shell()
fake_execute(
@@ -666,12 +663,9 @@ class TestShellCli(TestShell):
@mock.patch("os_client_config.config.OpenStackConfig._load_vendor_file")
@mock.patch("os_client_config.config.OpenStackConfig._load_config_file")
- @mock.patch("openstackclient.common.context._setup_handler_for_logging")
- def test_shell_args_precedence(self, setup_handler, config_mock,
- vendor_mock):
+ def test_shell_args_precedence(self, config_mock, vendor_mock):
config_mock.return_value = ('file.yaml', copy.deepcopy(CLOUD_2))
vendor_mock.return_value = ('file.yaml', copy.deepcopy(PUBLIC_1))
- setup_handler.return_value = mock.MagicMock()
_shell = make_shell()
# Test command option overriding config file value
@@ -723,12 +717,9 @@ class TestShellCliEnv(TestShell):
@mock.patch("os_client_config.config.OpenStackConfig._load_vendor_file")
@mock.patch("os_client_config.config.OpenStackConfig._load_config_file")
- @mock.patch("openstackclient.common.context._setup_handler_for_logging")
- def test_shell_args_precedence_1(self, setup_handler, config_mock,
- vendor_mock):
+ def test_shell_args_precedence_1(self, config_mock, vendor_mock):
config_mock.return_value = ('file.yaml', copy.deepcopy(CLOUD_2))
vendor_mock.return_value = ('file.yaml', copy.deepcopy(PUBLIC_1))
- setup_handler.return_value = mock.MagicMock()
_shell = make_shell()
# Test env var
@@ -767,12 +758,9 @@ class TestShellCliEnv(TestShell):
@mock.patch("os_client_config.config.OpenStackConfig._load_vendor_file")
@mock.patch("os_client_config.config.OpenStackConfig._load_config_file")
- @mock.patch("openstackclient.common.context._setup_handler_for_logging")
- def test_shell_args_precedence_2(self, setup_handler, config_mock,
- vendor_mock):
+ def test_shell_args_precedence_2(self, config_mock, vendor_mock):
config_mock.return_value = ('file.yaml', copy.deepcopy(CLOUD_2))
vendor_mock.return_value = ('file.yaml', copy.deepcopy(PUBLIC_1))
- setup_handler.return_value = mock.MagicMock()
_shell = make_shell()
# Test command option overriding config file value
@@ -810,77 +798,3 @@ class TestShellCliEnv(TestShell):
'krikkit',
_shell.cloud.config['region_name'],
)
-
-
-class TestShellCliLogging(TestShell):
- def setUp(self):
- super(TestShellCliLogging, self).setUp()
-
- def tearDown(self):
- super(TestShellCliLogging, self).tearDown()
-
- @mock.patch("os_client_config.config.OpenStackConfig._load_vendor_file")
- @mock.patch("os_client_config.config.OpenStackConfig._load_config_file")
- @mock.patch("openstackclient.common.context._setup_handler_for_logging")
- def test_shell_args_precedence_1(self, setup_handler, config_mock,
- vendor_mock):
- config_mock.return_value = ('file.yaml', copy.deepcopy(CLOUD_2))
- vendor_mock.return_value = ('file.yaml', copy.deepcopy(PUBLIC_1))
- setup_handler.return_value = mock.MagicMock()
- _shell = make_shell()
-
- # These come from clouds.yaml
- fake_execute(
- _shell,
- "--os-cloud megacloud list user",
- )
- self.assertEqual(
- 'megacloud',
- _shell.cloud.name,
- )
-
- self.assertEqual(
- '/tmp/test_log_file',
- _shell.cloud.config['log_file'],
- )
- self.assertEqual(
- 'debug',
- _shell.cloud.config['log_level'],
- )
-
- @mock.patch("os_client_config.config.OpenStackConfig._load_vendor_file")
- @mock.patch("os_client_config.config.OpenStackConfig._load_config_file")
- def test_shell_args_precedence_2(self, config_mock, vendor_mock):
- config_mock.return_value = ('file.yaml', copy.deepcopy(CLOUD_1))
- vendor_mock.return_value = ('file.yaml', copy.deepcopy(PUBLIC_1))
- _shell = make_shell()
-
- # Test operation_log_file not set
- fake_execute(
- _shell,
- "--os-cloud scc list user",
- )
- self.assertEqual(
- False,
- _shell.enable_operation_logging,
- )
-
- @mock.patch("os_client_config.config.OpenStackConfig._load_vendor_file")
- @mock.patch("os_client_config.config.OpenStackConfig._load_config_file")
- @mock.patch("openstackclient.common.context._setup_handler_for_logging")
- def test_shell_args_precedence_3(self, setup_handler, config_mock,
- vendor_mock):
- config_mock.return_value = ('file.yaml', copy.deepcopy(CLOUD_2))
- vendor_mock.return_value = ('file.yaml', copy.deepcopy(PUBLIC_1))
- setup_handler.return_value = mock.MagicMock()
- _shell = make_shell()
-
- # Test enable_operation_logging set
- fake_execute(
- _shell,
- "--os-cloud megacloud list user",
- )
- self.assertEqual(
- True,
- _shell.enable_operation_logging,
- )