aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/benchmark/contexts
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-03-12 09:53:40 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-03-12 09:53:40 +0000
commit066a45edd22be0fa7dec8986b850d672a86ad0a3 (patch)
tree9fdc414c907c5712c83a2967487b7238dd3510df /yardstick/tests/unit/benchmark/contexts
parent31efe64526ae5250b103a313c3041baa79864b5f (diff)
parent3478059d4397c5ee3a1d1e4707c5883afd0974a8 (diff)
Merge "assertTrue(mock.called) -> mock.assert_called"
Diffstat (limited to 'yardstick/tests/unit/benchmark/contexts')
-rw-r--r--yardstick/tests/unit/benchmark/contexts/test_heat.py2
-rw-r--r--yardstick/tests/unit/benchmark/contexts/test_kubernetes.py36
-rw-r--r--yardstick/tests/unit/benchmark/contexts/test_node.py18
3 files changed, 28 insertions, 28 deletions
diff --git a/yardstick/tests/unit/benchmark/contexts/test_heat.py b/yardstick/tests/unit/benchmark/contexts/test_heat.py
index c54a7ab12..625f97bf4 100644
--- a/yardstick/tests/unit/benchmark/contexts/test_heat.py
+++ b/yardstick/tests/unit/benchmark/contexts/test_heat.py
@@ -420,7 +420,7 @@ class HeatContextTestCase(unittest.TestCase):
self.test_context.key_filename = 'foo/bar/foobar'
self.test_context.undeploy()
mock_delete_key.assert_called()
- self.assertTrue(mock_template.delete.called)
+ mock_template.delete.assert_called_once()
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
def test_undeploy_no_teardown(self, mock_template):
diff --git a/yardstick/tests/unit/benchmark/contexts/test_kubernetes.py b/yardstick/tests/unit/benchmark/contexts/test_kubernetes.py
index 22153e4e8..4dd9d40d1 100644
--- a/yardstick/tests/unit/benchmark/contexts/test_kubernetes.py
+++ b/yardstick/tests/unit/benchmark/contexts/test_kubernetes.py
@@ -58,10 +58,10 @@ class KubernetesTestCase(unittest.TestCase):
mock_delete_services):
self.k8s_context.undeploy()
- self.assertTrue(mock_delete_ssh.called)
- self.assertTrue(mock_delete_rcs.called)
- self.assertTrue(mock_delete_pods.called)
- self.assertTrue(mock_delete_services.called)
+ mock_delete_ssh.assert_called_once()
+ mock_delete_rcs.assert_called_once()
+ mock_delete_pods.assert_called_once()
+ mock_delete_services.assert_called_once()
@mock.patch.object(kubernetes.KubernetesContext, '_create_services')
@mock.patch.object(kubernetes.KubernetesContext, '_wait_until_running')
@@ -77,11 +77,11 @@ class KubernetesTestCase(unittest.TestCase):
with mock.patch("yardstick.benchmark.contexts.kubernetes.time"):
self.k8s_context.deploy()
- self.assertTrue(mock_set_ssh_key.called)
- self.assertTrue(mock_create_rcs.called)
- self.assertTrue(mock_create_services.called)
- self.assertTrue(mock_get_rc_pods.called)
- self.assertTrue(mock_wait_until_running.called)
+ mock_set_ssh_key.assert_called_once()
+ mock_create_rcs.assert_called_once()
+ mock_create_services.assert_called_once()
+ mock_get_rc_pods.assert_called_once()
+ mock_wait_until_running.assert_called_once()
@mock.patch.object(kubernetes, 'paramiko', **{"resource_filename.return_value": ""})
@mock.patch.object(kubernetes, 'pkg_resources', **{"resource_filename.return_value": ""})
@@ -93,8 +93,8 @@ class KubernetesTestCase(unittest.TestCase):
self.k8s_context._set_ssh_key()
self.k8s_context._delete_ssh_key()
- self.assertTrue(mock_create.called)
- self.assertTrue(mock_delete.called)
+ mock_create.assert_called_once()
+ mock_delete.assert_called_once()
@mock.patch.object(kubernetes.k8s_utils, 'read_pod_status')
def test_wait_until_running(self, mock_read_pod_status):
@@ -136,34 +136,34 @@ class KubernetesTestCase(unittest.TestCase):
@mock.patch.object(kubernetes.KubernetesContext, '_create_rc')
def test_create_rcs(self, mock_create_rc):
self.k8s_context._create_rcs()
- self.assertTrue(mock_create_rc.called)
+ mock_create_rc.assert_called()
@mock.patch.object(kubernetes.k8s_utils, 'create_replication_controller')
def test_create_rc(self, mock_create_replication_controller):
self.k8s_context._create_rc({})
- self.assertTrue(mock_create_replication_controller.called)
+ mock_create_replication_controller.assert_called_once()
@mock.patch.object(kubernetes.KubernetesContext, '_delete_rc')
def test_delete_rcs(self, mock_delete_rc):
self.k8s_context._delete_rcs()
- self.assertTrue(mock_delete_rc.called)
+ mock_delete_rc.assert_called()
@mock.patch.object(kubernetes.k8s_utils, 'delete_replication_controller')
def test_delete_rc(self, mock_delete_replication_controller):
self.k8s_context._delete_rc({})
- self.assertTrue(mock_delete_replication_controller.called)
+ mock_delete_replication_controller.assert_called_once()
@mock.patch.object(kubernetes.k8s_utils, 'get_node_list')
def test_get_node_ip(self, mock_get_node_list):
self.k8s_context._get_node_ip()
- self.assertTrue(mock_get_node_list.called)
+ mock_get_node_list.assert_called_once()
@mock.patch('yardstick.orchestrator.kubernetes.ServiceObject.create')
def test_create_services(self, mock_create):
self.k8s_context._create_services()
- self.assertTrue(mock_create.called)
+ mock_create.assert_called()
@mock.patch('yardstick.orchestrator.kubernetes.ServiceObject.delete')
def test_delete_services(self, mock_delete):
self.k8s_context._delete_services()
- self.assertTrue(mock_delete.called)
+ mock_delete.assert_called()
diff --git a/yardstick/tests/unit/benchmark/contexts/test_node.py b/yardstick/tests/unit/benchmark/contexts/test_node.py
index 9761f6d53..8b232481b 100644
--- a/yardstick/tests/unit/benchmark/contexts/test_node.py
+++ b/yardstick/tests/unit/benchmark/contexts/test_node.py
@@ -176,7 +176,7 @@ class NodeContextTestCase(unittest.TestCase):
'type': 'script'
}
obj.deploy()
- self.assertTrue(dispatch_script_mock.called)
+ dispatch_script_mock.assert_called_once()
@mock.patch('{}.NodeContext._dispatch_ansible'.format(PREFIX))
def test_deploy_anisible(self, dispatch_ansible_mock):
@@ -186,7 +186,7 @@ class NodeContextTestCase(unittest.TestCase):
'type': 'ansible'
}
obj.deploy()
- self.assertTrue(dispatch_ansible_mock.called)
+ dispatch_ansible_mock.assert_called_once()
@mock.patch('{}.NodeContext._dispatch_script'.format(PREFIX))
def test_undeploy(self, dispatch_script_mock):
@@ -195,7 +195,7 @@ class NodeContextTestCase(unittest.TestCase):
'type': 'script'
}
obj.undeploy()
- self.assertTrue(dispatch_script_mock.called)
+ dispatch_script_mock.assert_called_once()
@mock.patch('{}.NodeContext._dispatch_ansible'.format(PREFIX))
def test_undeploy_anisble(self, dispatch_ansible_mock):
@@ -204,7 +204,7 @@ class NodeContextTestCase(unittest.TestCase):
'type': 'ansible'
}
obj.undeploy()
- self.assertTrue(dispatch_ansible_mock.called)
+ dispatch_ansible_mock.assert_called_once()
@mock.patch('{}.ssh.SSH._put_file_shell'.format(PREFIX))
@mock.patch('{}.ssh.SSH.execute'.format(PREFIX))
@@ -224,8 +224,8 @@ class NodeContextTestCase(unittest.TestCase):
execute_mock.return_value = (0, '', '')
obj._execute_remote_script('node5', info)
- self.assertTrue(put_file_mock.called)
- self.assertTrue(execute_mock.called)
+ put_file_mock.assert_called_once()
+ execute_mock.assert_called()
@mock.patch('{}.NodeContext._execute_local_script'.format(PREFIX))
def test_execute_script_local(self, local_execute_mock):
@@ -234,7 +234,7 @@ class NodeContextTestCase(unittest.TestCase):
obj = node.NodeContext()
self.addCleanup(obj._delete_context)
obj._execute_script(node_name, info)
- self.assertTrue(local_execute_mock.called)
+ local_execute_mock.assert_called_once()
@mock.patch('{}.NodeContext._execute_remote_script'.format(PREFIX))
def test_execute_script_remote(self, remote_execute_mock):
@@ -243,7 +243,7 @@ class NodeContextTestCase(unittest.TestCase):
obj = node.NodeContext()
self.addCleanup(obj._delete_context)
obj._execute_script(node_name, info)
- self.assertTrue(remote_execute_mock.called)
+ remote_execute_mock.assert_called_once()
def test_get_script(self):
script_args = 'hello.bash'
@@ -276,7 +276,7 @@ class NodeContextTestCase(unittest.TestCase):
'pwd': 'ubuntu',
}]
obj._get_client(node_name_args)
- self.assertTrue(wait_mock.called)
+ wait_mock.assert_called_once()
def test_get_server(self):
self.test_context.init(self.attrs)