Replace nova client create keypair with shade.
[yardstick.git] / yardstick / tests / unit / common / test_ansible_common.py
index 89ea128..48d8a60 100644 (file)
@@ -17,6 +17,7 @@ from __future__ import absolute_import
 
 import os
 import tempfile
+import shutil
 from collections import defaultdict
 
 import mock
@@ -99,7 +100,7 @@ class AnsibleNodeTestCase(unittest.TestCase):
 
     def test_ansible_node_getattr(self):
         a = ansible_common.AnsibleNode({"name": "name"})
-        self.assertEqual(getattr(a, "nosuch", None), None)
+        self.assertIsNone(getattr(a, "nosuch", None))
 
 
 class AnsibleNodeDictTestCase(unittest.TestCase):
@@ -145,7 +146,7 @@ class AnsibleNodeDictTestCase(unittest.TestCase):
 
 class AnsibleCommonTestCase(unittest.TestCase):
     def test_get_timeouts(self):
-        self.assertAlmostEquals(ansible_common.AnsibleCommon.get_timeout(-100), 1200.0)
+        self.assertAlmostEqual(ansible_common.AnsibleCommon.get_timeout(-100), 1200.0)
 
     def test__init__(self):
         ansible_common.AnsibleCommon({})
@@ -246,3 +247,18 @@ class AnsibleCommonTestCase(unittest.TestCase):
             a.execute_ansible('', d, ansible_check=True, verbose=True)
         finally:
             os.rmdir(d)
+
+    def test_get_sut_info(self):
+        d = tempfile.mkdtemp()
+        a = ansible_common.AnsibleCommon({})
+        try:
+            a.get_sut_info(d)
+        finally:
+            shutil.rmtree(d)
+
+    def test_get_sut_info_not_exist(self):
+        a = ansible_common.AnsibleCommon({})
+        try:
+            a.get_sut_info('/hello/world')
+        except OSError:
+            pass