-
Notifications
You must be signed in to change notification settings - Fork 667
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
93c01c3
commit d288b08
Showing
1 changed file
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import os | ||
import traceback | ||
|
||
from click.testing import CliRunner | ||
|
||
import config.main as config | ||
import show.main as show | ||
from utilities_common.db import Db | ||
|
||
class TestStormControl(object): | ||
@classmethod | ||
def setup_class(cls): | ||
os.environ['UTILITIES_UNIT_TESTING'] = "1" | ||
print("SETUP") | ||
|
||
def test_add_broadcast_storm(self): | ||
runner = CliRunner() | ||
db = Db() | ||
obj = {'db':db.cfgdb} | ||
|
||
result = runner.invoke(config.config.commands["storm_control"].commands["add"], ["Ethernet0", "broadcast", "10000"], obj = obj) | ||
print (result.exit_code) | ||
print (result.output) | ||
assert result.exit_code == 0 | ||
|
||
def test_add_uucast_storm(self): | ||
runner = CliRunner() | ||
db = Db() | ||
obj = {'db':db.cfgdb} | ||
|
||
result = runner.invoke(config.config.commands["storm_control"].commands["add"], ["Ethernet0", "unknown-unicast", "20000"], obj = obj) | ||
print (result.exit_code) | ||
print (result.output) | ||
assert result.exit_code == 0 | ||
|
||
def test_add_umcast_storm(self): | ||
runner = CliRunner() | ||
db = Db() | ||
obj = {'db':db.cfgdb} | ||
|
||
result = runner.invoke(config.config.commands["storm_control"].commands["add"], ["Ethernet0", "unknown-multicast", "30000"], obj = obj) | ||
print (result.exit_code) | ||
print (result.output) | ||
assert result.exit_code == 0 | ||
|
||
def test_del_broadcast_storm(self): | ||
runner = CliRunner() | ||
db = Db() | ||
obj = {'db':db.cfgdb} | ||
|
||
result = runner.invoke(config.config.commands["storm_control"].commands["del"], ["Ethernet0", "broadcast"], obj = obj) | ||
print (result.exit_code) | ||
print (result.output) | ||
assert result.exit_code == 0 | ||
|
||
def test_del_uucast_storm(self): | ||
runner = CliRunner() | ||
db = Db() | ||
obj = {'db':db.cfgdb} | ||
|
||
result = runner.invoke(config.config.commands["storm_control"].commands["del"], ["Ethernet0", "unknown-unicast"], obj = obj) | ||
print (result.exit_code) | ||
print (result.output) | ||
assert result.exit_code == 0 | ||
|
||
def test_del_umcast_storm(self): | ||
runner = CliRunner() | ||
db = Db() | ||
obj = {'db':db.cfgdb} | ||
|
||
result = runner.invoke(config.config.commands["storm_control"].commands["del"], ["Ethernet0", "unknown-multicast"], obj = obj) | ||
print (result.exit_code) | ||
print (result.output) | ||
assert result.exit_code == 0 | ||
|
||
def test_show_storm(self): | ||
runner = CliRunner() | ||
result = runner.invoke(show.cli.commands["storm-control"], []) | ||
print(result.exit_code) | ||
print(result.output) | ||
assert result.exit_code == 0 | ||
|
||
@classmethod | ||
def teardown_class(cls): | ||
os.environ['UTILITIES_UNIT_TESTING'] = "0" | ||
print("TEARDOWN") |