Freeze upstream versions
[netvirt.git] / resources / tools / odltools / odltools / netvirt / tests / test_analyze.py
1 # Copyright 2018 Red Hat, Inc. and others. All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 import logging
16 import unittest
17 from odltools import logg
18 from odltools import cli as root_cli
19 from odltools.netvirt import analyze
20 from odltools.netvirt import tests
21 from odltools.netvirt.tests import capture
22
23
24 class TestAnalyze(unittest.TestCase):
25     # TODO: capture stdout and check for list of tables.
26
27     def setUp(self):
28         logg.Logger(logging.INFO, logging.INFO)
29         self.args = tests.Args(path=tests.get_resources_path())
30
31     @unittest.skip("skipping")
32     def test_analyze_trunks(self):
33         analyze.analyze_trunks(self.args)
34
35     def test_analyze_interface(self):
36         self.args.ifname = "98c2e265-b4f2-40a5-8f31-2fb5d2b2baf6"
37         with capture.capture(analyze.analyze_interface, self.args) as output:
38             self.assertTrue("98c2e265-b4f2-40a5-8f31-2fb5d2b2baf6" in output)
39
40     def test_analyze_inventory(self):
41         self.args.store = "config"
42         self.args.nodeid = "132319289050514"
43         with capture.capture(analyze.analyze_inventory, self.args) as output:
44             self.assertTrue("132319289050514" in output)
45         self.args.store = "operational"
46         self.args.nodeid = "233201308854882"
47         # not a great test, but there are no flows in the operational
48         with capture.capture(analyze.analyze_inventory, self.args) as output:
49             self.assertTrue("Inventory Operational" in output)
50
51     @unittest.skip("skipping")
52     def test_analyze_nodes(self):
53         parser = root_cli.create_parser()
54         args = parser.parse_args(["analyze", "nodes", "-p", "--path=" + tests.get_resources_path()])
55         with capture.capture(args.func, args) as output:
56             self.assertTrue("203251201875890" in output)
57
58
59 if __name__ == '__main__':
60     unittest.main()