summaryrefslogtreecommitdiff
path: root/tests
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
parentf4b5ef39f6f84e66af532583040c9be7556e9b69 (diff)
downloadpython-openstackclient-11d3ba457018ac2179669309c65d806c53476649.tar.gz
Add openstackclient bits
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py0
-rw-r--r--tests/test_utils.py51
-rw-r--r--tests/utils.py7
3 files changed, 58 insertions, 0 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/__init__.py
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')
diff --git a/tests/utils.py b/tests/utils.py
new file mode 100644
index 00000000..25452d5c
--- /dev/null
+++ b/tests/utils.py
@@ -0,0 +1,7 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+import unittest
+
+
+class TestCase(unittest.TestCase):
+ pass