add yardstick iruya 9.0.0 release notes
[yardstick.git] / yardstick / tests / unit / service / test_environment.py
1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
3 #
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 ##############################################################################
9
10 import mock
11
12 from yardstick.common import exceptions
13 from yardstick.service import environment
14 from yardstick.tests.unit import base as ut_base
15
16
17 class EnvironmentTestCase(ut_base.BaseUnitTestCase):
18
19     def test_get_sut_info(self):
20         pod_info = {
21             'nodes': [
22                 {
23                     'name': 'node1',
24                     'host_name': 'host1',
25                     'role': 'Controller',
26                     'ip': '10.1.0.50',
27                     'user': 'root',
28                     'passward': 'root'
29                 }
30             ]
31         }
32
33         with mock.patch.object(environment.AnsibleCommon,
34                                'gen_inventory_ini_dict'), \
35                 mock.patch.object(environment.AnsibleCommon, 'get_sut_info',
36                                   return_value={'node1': {}}), \
37                 mock.patch.object(environment.Environment, '_format_sut_info'):
38             env = environment.Environment(pod=pod_info)
39             env.get_sut_info()
40
41     def test_get_sut_info_pod_str(self):
42         pod_info = 'nodes'
43
44         env = environment.Environment(pod=pod_info)
45         with self.assertRaises(exceptions.UnsupportedPodFormatError):
46             env.get_sut_info()