1 ##############################################################################
2 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
12 from yardstick.benchmark.scenarios.lib.get_migrate_target_host import GetMigrateTargetHost
14 BASE = 'yardstick.benchmark.scenarios.lib.get_migrate_target_host'
17 class GetMigrateTargetHostTestCase(unittest.TestCase):
19 @mock.patch('{}.openstack_utils.get_nova_client'.format(BASE))
20 @mock.patch('{}.GetMigrateTargetHost._get_migrate_host'.format(BASE))
21 @mock.patch('{}.GetMigrateTargetHost._get_current_host_name'.format(BASE))
22 def test_get_migrate_target_host(self,
23 mock_get_current_host_name,
24 mock_get_migrate_host,
25 mock_get_nova_client):
26 obj = GetMigrateTargetHost({}, {})
28 mock_get_nova_client.assert_called_once()
29 mock_get_current_host_name.assert_called_once()
30 mock_get_migrate_host.assert_called_once()
32 @mock.patch('{}.openstack_utils.get_nova_client'.format(BASE))
33 def test_get_migrate_host(self, mock_get_nova_client):
35 def __init__(self, service):
36 self.service = service
39 mock_get_nova_client().hosts.list_all.return_value = [A('compute')]
40 obj = GetMigrateTargetHost({}, {})
41 host = obj._get_migrate_host('host5')
42 mock_get_nova_client.assert_called()
43 self.assertEqual(host, 'host4')