test_create_keypair: fix op_utils mock and mock paramiko 67/40967/1
authorRoss Brattain <ross.b.brattain@intel.com>
Mon, 4 Sep 2017 03:30:40 +0000 (20:30 -0700)
committerRoss Brattain <ross.b.brattain@intel.com>
Mon, 4 Sep 2017 03:33:52 +0000 (20:33 -0700)
Change-Id: I5c039c0d4f4ba651209c7d5ca4e748f9151b5630
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
tests/unit/benchmark/scenarios/lib/test_create_keypair.py

index 99e6b9a..4b9b720 100644 (file)
@@ -8,15 +8,16 @@
 ##############################################################################
 import unittest
 import mock
-import paramiko
 
 from yardstick.benchmark.scenarios.lib.create_keypair import CreateKeypair
 
+PREFIX = "yardstick.benchmark.scenarios.lib.create_keypair"
 
-class CreateKeypairTestCase(unittest.TestCase):
 
-    @mock.patch('yardstick.common.openstack_utils.create_keypair')
-    def test_create_keypair(self, mock_create_keypair):
+class CreateKeypairTestCase(unittest.TestCase):
+    @mock.patch('{}.paramiko'.format(PREFIX))
+    @mock.patch('{}.op_utils'.format(PREFIX))
+    def test_create_keypair(self, mock_op_utils, mock_paramiko):
         options = {
             'key_name': 'yardstick_key',
             'key_path': '/tmp/yardstick_key'
@@ -24,7 +25,7 @@ class CreateKeypairTestCase(unittest.TestCase):
         args = {"options": options}
         obj = CreateKeypair(args, {})
         obj.run({})
-        self.assertTrue(mock_create_keypair.called)
+        self.assertTrue(mock_op_utils.create_keypair.called)
 
 
 def main():