aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests
diff options
context:
space:
mode:
Diffstat (limited to 'functest/tests')
-rw-r--r--functest/tests/unit/openstack/rally/test_rally.py26
-rw-r--r--functest/tests/unit/openstack/tempest/test_tempest.py6
-rw-r--r--functest/tests/unit/openstack/vping/test_vping_ssh.py24
-rw-r--r--functest/tests/unit/vnf/ims/test_clearwater.py1
4 files changed, 40 insertions, 17 deletions
diff --git a/functest/tests/unit/openstack/rally/test_rally.py b/functest/tests/unit/openstack/rally/test_rally.py
index 226d4e69a..5ab82ecc4 100644
--- a/functest/tests/unit/openstack/rally/test_rally.py
+++ b/functest/tests/unit/openstack/rally/test_rally.py
@@ -103,15 +103,19 @@ class OSRallyTesting(unittest.TestCase):
mock_method.assert_called()
mock_os_makedirs.assert_called()
- def test_get_task_id_default(self):
- cmd_raw = b'Task 1: started'
- self.assertEqual(self.rally_base.get_task_id(cmd_raw),
- '1')
-
- def test_get_task_id_missing_id(self):
- cmd_raw = b''
- self.assertEqual(self.rally_base.get_task_id(cmd_raw),
- None)
+ @mock.patch('subprocess.check_output', return_value=b'1\n')
+ def test_get_task_id_default(self, *args):
+ tag = 'nova'
+ self.assertEqual(self.rally_base.get_task_id(tag), '1')
+ args[0].assert_called_with(
+ ['rally', 'task', 'list', '--tag', tag, '--uuids-only'])
+
+ @mock.patch('subprocess.check_output', return_value=b'\n')
+ def test_get_task_id_missing_id(self, *args):
+ tag = 'nova'
+ self.assertEqual(self.rally_base.get_task_id(tag), '')
+ args[0].assert_called_with(
+ ['rally', 'task', 'list', '--tag', tag, '--uuids-only'])
def test_task_succeed_fail(self):
json_raw = json.dumps({})
@@ -291,8 +295,8 @@ class OSRallyTesting(unittest.TestCase):
def test_prepare_run_flavor_alt_creation_failed(self, *args):
# pylint: disable=unused-argument
self.rally_base.stests = ['test1', 'test2']
- with mock.patch.object(self.rally_base.cloud,
- 'list_hypervisors') as mock_list_hyperv, \
+ with mock.patch.object(self.rally_base, 'count_hypervisors') \
+ as mock_list_hyperv, \
mock.patch.object(self.rally_base, 'create_flavor_alt',
side_effect=Exception) \
as mock_create_flavor:
diff --git a/functest/tests/unit/openstack/tempest/test_tempest.py b/functest/tests/unit/openstack/tempest/test_tempest.py
index 87438ae7c..71aa5a257 100644
--- a/functest/tests/unit/openstack/tempest/test_tempest.py
+++ b/functest/tests/unit/openstack/tempest/test_tempest.py
@@ -125,7 +125,8 @@ class OSTempestTesting(unittest.TestCase):
return_value=['test1', 'test2']):
self.tempestcommon.tempest_blacklist = Exception
os.environ['DEPLOY_SCENARIO'] = 'deploy_scenario'
- self.tempestcommon.apply_tempest_blacklist()
+ self.tempestcommon.apply_tempest_blacklist(
+ self.tempestcommon.tempest_blacklist)
obj = mock_open()
obj.write.assert_any_call('test1\n')
obj.write.assert_any_call('test2\n')
@@ -147,7 +148,8 @@ class OSTempestTesting(unittest.TestCase):
mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
'yaml.safe_load', return_value=item_dict):
os.environ['DEPLOY_SCENARIO'] = 'deploy_scenario'
- self.tempestcommon.apply_tempest_blacklist()
+ self.tempestcommon.apply_tempest_blacklist(
+ self.tempestcommon.tempest_blacklist)
obj = mock_open()
obj.write.assert_any_call('test1\n')
self.assertFalse(obj.write.assert_any_call('test2\n'))
diff --git a/functest/tests/unit/openstack/vping/test_vping_ssh.py b/functest/tests/unit/openstack/vping/test_vping_ssh.py
index 05482ed6b..98afe0853 100644
--- a/functest/tests/unit/openstack/vping/test_vping_ssh.py
+++ b/functest/tests/unit/openstack/vping/test_vping_ssh.py
@@ -61,22 +61,38 @@ class VpingSSHTesting(unittest.TestCase):
'{}-vm2_{}'.format(self.vping.case_name, self.vping.guid),
security_groups=[self.vping.sec.id])
- def test_execute_exc(self):
- self.vping.vm2 = munch.Munch(private_v4='127.0.0.1')
+ @mock.patch('functest.opnfv_tests.openstack.vping.vping_ssh.VPingSSH.'
+ 'check_regex_in_console', return_value=True)
+ def test_execute_exc(self, *args):
+ self.vping.vm2 = munch.Munch(private_v4='127.0.0.1', name='foo')
self.vping.ssh = mock.Mock()
self.vping.ssh.exec_command.side_effect = ssh_exception.SSHException
with self.assertRaises(ssh_exception.SSHException):
self.vping.execute()
self.vping.ssh.exec_command.assert_called_once_with(
'ping -c 1 {}'.format(self.vping.vm2.private_v4))
+ args[0].assert_called_once_with('foo')
+
+ @mock.patch('functest.opnfv_tests.openstack.vping.vping_ssh.VPingSSH.'
+ 'check_regex_in_console', return_value=False)
+ def test_execute_exc2(self, *args):
+ self.vping.vm2 = munch.Munch(private_v4='127.0.0.1', name='foo')
+ self.vping.ssh = mock.Mock()
+ self.vping.execute()
+ self.vping.ssh.exec_command.assert_not_called()
+ args[0].assert_called_once_with('foo')
def _test_execute(self, ret=0):
- self.vping.vm2 = munch.Munch(private_v4='127.0.0.1')
+ self.vping.vm2 = munch.Munch(private_v4='127.0.0.1', name='foo')
self.vping.ssh = mock.Mock()
stdout = mock.Mock()
stdout.channel.recv_exit_status.return_value = ret
self.vping.ssh.exec_command.return_value = (None, stdout, mock.Mock())
- self.assertEqual(self.vping.execute(), ret)
+ with mock.patch('functest.opnfv_tests.openstack.vping.vping_ssh.'
+ 'VPingSSH.check_regex_in_console',
+ return_value=True) as mock_check:
+ self.assertEqual(self.vping.execute(), ret)
+ mock_check.assert_called_once_with('foo')
self.vping.ssh.exec_command.assert_called_once_with(
'ping -c 1 {}'.format(self.vping.vm2.private_v4))
diff --git a/functest/tests/unit/vnf/ims/test_clearwater.py b/functest/tests/unit/vnf/ims/test_clearwater.py
index 435b172db..f590a2857 100644
--- a/functest/tests/unit/vnf/ims/test_clearwater.py
+++ b/functest/tests/unit/vnf/ims/test_clearwater.py
@@ -38,6 +38,7 @@ class ClearwaterTesting(unittest.TestCase):
'cookies': ""}
self.mock_post_200.configure_mock(**attrs)
+
if __name__ == "__main__":
logging.disable(logging.CRITICAL)
unittest.main(verbosity=2)