aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2018-03-14 09:41:01 +0000
committerchenjiankun <chenjiankun1@huawei.com>2018-03-15 06:56:37 +0000
commitc3f91fac56cd938c408c62ff44f5ff039b1fd8e6 (patch)
treebe2c5a64a4908fc5acc0ddf28e798720cbf01cb8 /yardstick/tests
parent4b8b674b65830a24230faed71e8d9a1048139c89 (diff)
Create API to get SUT information
JIRA: YARDSTICK-1072 We need to show SUT information in GUI. Change-Id: I40bcd513f3c6a443c82764687637ac5258b99584 Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'yardstick/tests')
-rw-r--r--yardstick/tests/unit/service/__init__.py0
-rw-r--r--yardstick/tests/unit/service/test_environment.py49
2 files changed, 49 insertions, 0 deletions
diff --git a/yardstick/tests/unit/service/__init__.py b/yardstick/tests/unit/service/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/yardstick/tests/unit/service/__init__.py
diff --git a/yardstick/tests/unit/service/test_environment.py b/yardstick/tests/unit/service/test_environment.py
new file mode 100644
index 000000000..4af9a3958
--- /dev/null
+++ b/yardstick/tests/unit/service/test_environment.py
@@ -0,0 +1,49 @@
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import unittest
+
+import mock
+
+from yardstick.service.environment import Environment
+from yardstick.service.environment import AnsibleCommon
+from yardstick.common.exceptions import UnsupportedPodFormatError
+
+
+class EnvironmentTestCase(unittest.TestCase):
+
+ def test_get_sut_info(self):
+ pod_info = {
+ 'nodes': [
+ {
+ 'name': 'node1',
+ 'host_name': 'host1',
+ 'role': 'Controller',
+ 'ip': '10.1.0.50',
+ 'user': 'root',
+ 'passward': 'root'
+ }
+ ]
+ }
+
+ AnsibleCommon.gen_inventory_ini_dict = mock.MagicMock()
+ AnsibleCommon.get_sut_info = mock.MagicMock(return_value={'node1': {}})
+
+ env = Environment(pod=pod_info)
+ env.get_sut_info()
+
+ def test_get_sut_info_pod_str(self):
+ pod_info = 'nodes'
+
+ env = Environment(pod=pod_info)
+ with self.assertRaises(UnsupportedPodFormatError):
+ env.get_sut_info()
+
+
+if __name__ == '__main__':
+ unittest.main()