diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2017-11-29 11:17:19 -0600 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2017-12-07 08:10:23 -0600 |
| commit | 1d914dd9ad9cb9e5d7bba2dab50d9e292c149842 (patch) | |
| tree | 776776b6edb466075f1ac2dd66d6ed86692cbf12 /openstackclient/tests/unit/integ/cli/test_shell.py | |
| parent | 396cde37a36890f1387695a90963f188fbb39c5a (diff) | |
| download | python-openstackclient-1d914dd9ad9cb9e5d7bba2dab50d9e292c149842.tar.gz | |
Fix SDK Connection creation alternative to Profile
Do a dummy import to determine which SDK is installed (Pre/post merge).
This solves the DevStack error "Cloud defaults was not found" in -tips jobs.
Depends-On: Ia111f127fbdceac2afe20fd9d1fe032145cdd72c
Change-Id: I60c2d418dd5a393eee2cc2a5c2fdebfffdabf2d3
Diffstat (limited to 'openstackclient/tests/unit/integ/cli/test_shell.py')
| -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 " |
