diff options
Diffstat (limited to 'openstackclient/tests')
| -rw-r--r-- | openstackclient/tests/unit/integ/cli/test_shell.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/openstackclient/tests/unit/integ/cli/test_shell.py b/openstackclient/tests/unit/integ/cli/test_shell.py index 78663fbc..70303be3 100644 --- a/openstackclient/tests/unit/integ/cli/test_shell.py +++ b/openstackclient/tests/unit/integ/cli/test_shell.py @@ -19,6 +19,16 @@ from openstackclient import shell from openstackclient.tests.unit.integ import base as test_base from openstackclient.tests.unit import test_shell +# NOTE(dtroyer): Attempt the import to detect if the SDK installed is new +# enough to contain the os_client_config code. If so, use +# that path for mocks. +CONFIG_MOCK_BASE = "openstack.config.loader" +try: + from openstack.config import defaults # noqa +except ImportError: + # Fall back to os-client-config + CONFIG_MOCK_BASE = "os_client_config.config" + class TestIntegShellCliV2(test_base.TestInteg): @@ -389,8 +399,8 @@ class TestIntegShellCliPrecedenceOCC(test_base.TestInteg): test_shell.PUBLIC_1['public-clouds']['megadodo']['auth']['auth_url'] \ = test_base.V3_AUTH_URL - @mock.patch("os_client_config.config.OpenStackConfig._load_vendor_file") - @mock.patch("os_client_config.config.OpenStackConfig._load_config_file") + @mock.patch(CONFIG_MOCK_BASE + ".OpenStackConfig._load_vendor_file") + @mock.patch(CONFIG_MOCK_BASE + ".OpenStackConfig._load_config_file") def test_shell_args_precedence_1(self, config_mock, vendor_mock): """Precedence run 1 @@ -405,6 +415,7 @@ class TestIntegShellCliPrecedenceOCC(test_base.TestInteg): return ('file.yaml', copy.deepcopy(test_shell.PUBLIC_1)) vendor_mock.side_effect = vendor_mock_return + print("CONFIG_MOCK_BASE=%s" % CONFIG_MOCK_BASE) _shell = shell.OpenStackShell() _shell.run( "--os-password qaz configuration show".split(), @@ -458,8 +469,8 @@ class TestIntegShellCliPrecedenceOCC(test_base.TestInteg): # +env, +cli, +occ # see test_shell_args_precedence_2() - @mock.patch("os_client_config.config.OpenStackConfig._load_vendor_file") - @mock.patch("os_client_config.config.OpenStackConfig._load_config_file") + @mock.patch(CONFIG_MOCK_BASE + ".OpenStackConfig._load_vendor_file") + @mock.patch(CONFIG_MOCK_BASE + ".OpenStackConfig._load_config_file") def test_shell_args_precedence_2(self, config_mock, vendor_mock): """Precedence run 2 @@ -474,6 +485,7 @@ class TestIntegShellCliPrecedenceOCC(test_base.TestInteg): return ('file.yaml', copy.deepcopy(test_shell.PUBLIC_1)) vendor_mock.side_effect = vendor_mock_return + print("CONFIG_MOCK_BASE=%s" % CONFIG_MOCK_BASE) _shell = shell.OpenStackShell() _shell.run( "--os-username zarquon --os-password qaz " |
