summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClint Byrum <clint@fewbar.com>2015-02-26 16:12:14 -0800
committerClint Byrum <clint@fewbar.com>2015-02-26 16:22:35 -0800
commit076e9bd9bece61db43137eab553c1545e6701fca (patch)
treec106f693e520de033b15170986143b01db9634a9
parent7385528671ea61617d7027fc33897ea850e7364c (diff)
downloados-client-config-076e9bd9bece61db43137eab553c1545e6701fca.tar.gz
Add basic unit test for config
Adding this exposed some python3 compatibility issues with iteritems. Change-Id: Ia78bd8edd17c7d2360ad958b3de734503d400774
-rw-r--r--os_client_config/config.py4
-rw-r--r--os_client_config/tests/test_config.py24
2 files changed, 26 insertions, 2 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py
index f8adc04..7c50b5d 100644
--- a/os_client_config/config.py
+++ b/os_client_config/config.py
@@ -197,7 +197,7 @@ class OpenStackConfig(object):
os_args = dict()
new_args = dict()
- for (key, val) in args.iteritems():
+ for (key, val) in iter(args.items()):
key = key.replace('-', '_')
if key.startswith('os'):
os_args[key[3:]] = val
@@ -285,7 +285,7 @@ class OpenStackConfig(object):
config['auth'] = dict()
# Can't just do update, because None values take over
- for (key, val) in args.iteritems():
+ for (key, val) in iter(args.items()):
if val is not None:
config[key] = val
diff --git a/os_client_config/tests/test_config.py b/os_client_config/tests/test_config.py
new file mode 100644
index 0000000..2b1821e
--- /dev/null
+++ b/os_client_config/tests/test_config.py
@@ -0,0 +1,24 @@
+# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import testtools
+
+from os_client_config import cloud_config
+from os_client_config import config
+
+
+class TestConfig(testtools.TestCase):
+ def test_get_one_cloud(self):
+ c = config.OpenStackConfig()
+ self.assertIsInstance(c.get_one_cloud(), cloud_config.CloudConfig)