summaryrefslogtreecommitdiff
path: root/tests/v1_1/utils.py
diff options
context:
space:
mode:
authorSandy Walsh <sandy@sandywalsh.com>2011-08-05 06:40:34 -0700
committerSandy Walsh <sandy@sandywalsh.com>2011-08-05 06:40:34 -0700
commitd81b0d84c1aef8955c45a5117239baba1058dc85 (patch)
tree967758b47a49ec8ab26f3c67e241d91d66ab0d90 /tests/v1_1/utils.py
parent4b8879a8eb3fb80494ff16d4b96490fec9aa2161 (diff)
parent6fa86a22409ab73911168b2a0aa70f9adb583abf (diff)
downloadpython-novaclient-d81b0d84c1aef8955c45a5117239baba1058dc85.tar.gz
manual merge2.6.0
Diffstat (limited to 'tests/v1_1/utils.py')
-rw-r--r--tests/v1_1/utils.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/v1_1/utils.py b/tests/v1_1/utils.py
new file mode 100644
index 00000000..f878a5e2
--- /dev/null
+++ b/tests/v1_1/utils.py
@@ -0,0 +1,29 @@
+from nose.tools import ok_
+
+
+def fail(msg):
+ raise AssertionError(msg)
+
+
+def assert_in(thing, seq, msg=None):
+ msg = msg or "'%s' not found in %s" % (thing, seq)
+ ok_(thing in seq, msg)
+
+
+def assert_not_in(thing, seq, msg=None):
+ msg = msg or "unexpected '%s' found in %s" % (thing, seq)
+ ok_(thing not in seq, msg)
+
+
+def assert_has_keys(dict, required=[], optional=[]):
+ keys = dict.keys()
+ for k in required:
+ assert_in(k, keys, "required key %s missing from %s" % (k, dict))
+ allowed_keys = set(required) | set(optional)
+ extra_keys = set(keys).difference(set(required + optional))
+ if extra_keys:
+ fail("found unexpected keys: %s" % list(extra_keys))
+
+
+def assert_isinstance(thing, kls):
+ ok_(isinstance(thing, kls), "%s is not an instance of %s" % (thing, kls))