1 # Copyright 2018 Red Hat, Inc. and others. All Rights Reserved.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 from odltools import logg
18 from odltools import cli as root_cli
19 from odltools.netvirt import show
20 from odltools.netvirt import tests
21 from odltools.netvirt.tests import capture
24 class TestShow(unittest.TestCase):
25 # TODO: capture stdout and check for list of tables.
28 logg.Logger(logging.INFO, logging.INFO)
29 self.args = tests.Args(path=tests.get_resources_path())
30 # self.args = tests.Args(path="/tmp/testmodels")
32 def test_show_elan_instances(self):
33 with capture.capture(show.show_elan_instances, self.args) as output:
34 self.assertTrue("ElanInstance: a5fe7476-9aa1-4bfb-aec4-05d7a1376f45" in output)
36 def test_show_groups(self):
37 with capture.capture(show.show_groups, self.args) as output:
38 self.assertTrue("Dpn: 74851789353527," in output)
40 def test_show_flows_all(self):
41 self.args.flowtype = "all"
42 self.args.pretty_print = True
43 self.args.modules = None
44 self.args.metaonly = None
45 with capture.capture(show.show_flows, self.args) as output:
46 self.assertTrue("FlowId:748517893535270tunf68aef23130" in output)
48 def test_show_stale_bindings(self):
49 show.show_stale_bindings(self.args)
51 @unittest.skip("skipping")
52 # changed the show tables output to show names too
53 def test_show_tables(self):
54 # TODO: different tables for Fluorine
55 expected = "[0, 17, 18, 19, 20, 21, 22, 23, 24, 36, 38, " \
56 "43, 45, 48, 50, 51, 52, 55, 60, 80, 81, 210, " \
57 "211, 212, 213, 214, 215, 216, 217, 90, 220, " \
58 "239, 240, 241, 242, 243, 244, 245, 246, 247]\n"
59 with capture.capture(show.show_tables, self.args) as output:
60 self.assertEqual(expected, output)
63 @unittest.skip("skipping")
65 def test_show_idpools(self):
66 parser = root_cli.create_parser()
67 args = parser.parse_args(["show", "id-pools", "-p", "--path=" + tests.get_resources_path()])
68 with capture.capture(args.func, args) as output:
69 self.assertTrue("interfaces" in output)
71 def test_show_neutron2(self):
72 parser = root_cli.create_parser()
73 args = parser.parse_args(["show", "neutron", "ports", "-p", "--path=" + tests.get_resources_path()])
74 with capture.capture(args.func, args) as output:
75 self.assertTrue("8e3c262e-7b45-4222-ac4e-528db75e5516" in output)
77 def test_show_neutron(self):
78 self.args.object = "ports"
79 self.args.pretty_print = True
80 self.args.short = True
81 with capture.capture(show.show_neutron, self.args) as output:
82 self.assertTrue("8e3c262e-7b45-4222-ac4e-528db75e5516" in output)
85 if __name__ == '__main__':