Merge "Modify the Docker diff file for ARM64"
[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 import unittest
10
11 import mock
12
13 from yardstick.service.environment import Environment
14 from yardstick.service.environment import AnsibleCommon
15 from yardstick.common.exceptions import UnsupportedPodFormatError
16
17
18 class EnvironmentTestCase(unittest.TestCase):
19
20     def test_get_sut_info(self):
21         pod_info = {
22             'nodes': [
23                 {
24                     'name': 'node1',
25                     'host_name': 'host1',
26                     'role': 'Controller',
27                     'ip': '10.1.0.50',
28                     'user': 'root',
29                     'passward': 'root'
30                 }
31             ]
32         }
33
34         AnsibleCommon.gen_inventory_ini_dict = mock.MagicMock()
35         AnsibleCommon.get_sut_info = mock.MagicMock(return_value={'node1': {}})
36
37         env = Environment(pod=pod_info)
38         env.get_sut_info()
39
40     def test_get_sut_info_pod_str(self):
41         pod_info = 'nodes'
42
43         env = Environment(pod=pod_info)
44         with self.assertRaises(UnsupportedPodFormatError):
45             env.get_sut_info()
46
47
48 if __name__ == '__main__':
49     unittest.main()