JIRA: BOTTLENECKS-29
[bottlenecks.git] / vstf / vstf / controller / unittest / test_collect.py
1 ##############################################################################
2 # Copyright (c) 2015 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 unittest
11 import json
12
13 from vstf.controller.env_build import env_collect
14 from vstf.controller.unittest import model
15
16
17 class TestCollect(model.Test):
18     
19     def setUp(self):
20         super(TestCollect, self).setUp()
21         self.obj = env_collect.EnvCollectApi(self.conn)
22         
23     def test_collect_host_info(self):
24         ret_str = json.dumps(self.obj.collect_host_info(self.tester_host), indent = 4)
25         for key in ("CPU INFO","MEMORY INFO","HW_INFO","OS INFO"):
26             self.assertTrue(key in ret_str, "collect_host_info failed, ret_str = %s" % ret_str)
27             
28     def test_list_nic_devices(self):
29         ret_str = json.dumps(self.obj.list_nic_devices(self.tester_host), indent = 4)
30         for key in ("device","mac","bdf","desc"):
31             self.assertTrue(key in ret_str, "list_nic_devices failed, ret_str = %s" % ret_str)
32         print ret_str
33     
34     def test_get_device_detail(self):
35         identity = "01:00.0"
36         ret = self.obj.get_device_detail(self.tester_host, "01:00.0")
37         for key in ("device","mac","bdf","desc"):
38             self.assertTrue(key in ret)
39         self.assertTrue(ret['bdf'] == identity)
40
41
42 if __name__ == "__main__":
43     import logging
44     logging.basicConfig(level = logging.INFO)
45     unittest.main()