summaryrefslogtreecommitdiff
path: root/tests/test_utils.py
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2012-04-19 22:41:44 -0500
committerDean Troyer <dtroyer@gmail.com>2012-04-19 22:41:44 -0500
commit11d3ba457018ac2179669309c65d806c53476649 (patch)
tree6501297f905bb19d88755dd4cce8fcea35de4ae8 /tests/test_utils.py
parentf4b5ef39f6f84e66af532583040c9be7556e9b69 (diff)
downloadpython-openstackclient-11d3ba457018ac2179669309c65d806c53476649.tar.gz
Add openstackclient bits
Diffstat (limited to 'tests/test_utils.py')
-rw-r--r--tests/test_utils.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py
new file mode 100644
index 00000000..c8d24966
--- /dev/null
+++ b/tests/test_utils.py
@@ -0,0 +1,51 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+from openstackclient import utils as os_utils
+from tests import utils
+
+OBJ_LIST = [
+ {
+ 'id': '123',
+ 'name': 'foo',
+ 'extra': {
+ 'desc': 'foo fu',
+ 'status': 'present',
+ }
+ },
+ {
+ 'id': 'abc',
+ 'name': 'bar',
+ 'extra': {
+ 'desc': 'babar',
+ 'status': 'waiting',
+ }
+ }
+ ]
+
+
+class Obj(object):
+
+ def __init__(self):
+ pass
+
+
+class UtilsTest(utils.TestCase):
+
+ def setUp(self):
+ super(UtilsTest, self).setUp()
+ self.objs = []
+ for o in OBJ_LIST:
+ obj = Obj()
+ for k in o.keys():
+ setattr(obj, k, o.get(k))
+ self.objs.append(obj)
+
+ def tearDown(self):
+ super(UtilsTest, self).tearDown()
+ self.objs = []
+
+ def test_expand_meta(self):
+ ret = os_utils.expand_meta(self.objs, 'extra')
+ assert (getattr(ret[0], 'desc') == 'foo fu')
+ assert (getattr(ret[0], 'status') == 'present')
+ assert (getattr(ret[0], 'extra', 'qaz') == 'qaz')