Skip to content

Commit d288b08

Browse files
storm-control config/show test code
1 parent 93c01c3 commit d288b08

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

tests/storm_control_test.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import os
2+
import traceback
3+
4+
from click.testing import CliRunner
5+
6+
import config.main as config
7+
import show.main as show
8+
from utilities_common.db import Db
9+
10+
class TestStormControl(object):
11+
@classmethod
12+
def setup_class(cls):
13+
os.environ['UTILITIES_UNIT_TESTING'] = "1"
14+
print("SETUP")
15+
16+
def test_add_broadcast_storm(self):
17+
runner = CliRunner()
18+
db = Db()
19+
obj = {'db':db.cfgdb}
20+
21+
result = runner.invoke(config.config.commands["storm_control"].commands["add"], ["Ethernet0", "broadcast", "10000"], obj = obj)
22+
print (result.exit_code)
23+
print (result.output)
24+
assert result.exit_code == 0
25+
26+
def test_add_uucast_storm(self):
27+
runner = CliRunner()
28+
db = Db()
29+
obj = {'db':db.cfgdb}
30+
31+
result = runner.invoke(config.config.commands["storm_control"].commands["add"], ["Ethernet0", "unknown-unicast", "20000"], obj = obj)
32+
print (result.exit_code)
33+
print (result.output)
34+
assert result.exit_code == 0
35+
36+
def test_add_umcast_storm(self):
37+
runner = CliRunner()
38+
db = Db()
39+
obj = {'db':db.cfgdb}
40+
41+
result = runner.invoke(config.config.commands["storm_control"].commands["add"], ["Ethernet0", "unknown-multicast", "30000"], obj = obj)
42+
print (result.exit_code)
43+
print (result.output)
44+
assert result.exit_code == 0
45+
46+
def test_del_broadcast_storm(self):
47+
runner = CliRunner()
48+
db = Db()
49+
obj = {'db':db.cfgdb}
50+
51+
result = runner.invoke(config.config.commands["storm_control"].commands["del"], ["Ethernet0", "broadcast"], obj = obj)
52+
print (result.exit_code)
53+
print (result.output)
54+
assert result.exit_code == 0
55+
56+
def test_del_uucast_storm(self):
57+
runner = CliRunner()
58+
db = Db()
59+
obj = {'db':db.cfgdb}
60+
61+
result = runner.invoke(config.config.commands["storm_control"].commands["del"], ["Ethernet0", "unknown-unicast"], obj = obj)
62+
print (result.exit_code)
63+
print (result.output)
64+
assert result.exit_code == 0
65+
66+
def test_del_umcast_storm(self):
67+
runner = CliRunner()
68+
db = Db()
69+
obj = {'db':db.cfgdb}
70+
71+
result = runner.invoke(config.config.commands["storm_control"].commands["del"], ["Ethernet0", "unknown-multicast"], obj = obj)
72+
print (result.exit_code)
73+
print (result.output)
74+
assert result.exit_code == 0
75+
76+
def test_show_storm(self):
77+
runner = CliRunner()
78+
result = runner.invoke(show.cli.commands["storm-control"], [])
79+
print(result.exit_code)
80+
print(result.output)
81+
assert result.exit_code == 0
82+
83+
@classmethod
84+
def teardown_class(cls):
85+
os.environ['UTILITIES_UNIT_TESTING'] = "0"
86+
print("TEARDOWN")

0 commit comments

Comments
 (0)