forked from sonic-net/sonic-utilities
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgearbox_test.py
51 lines (43 loc) · 2.09 KB
/
gearbox_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import sys
import os
from click.testing import CliRunner
from unittest import TestCase
test_path = os.path.dirname(os.path.abspath(__file__))
modules_path = os.path.dirname(test_path)
scripts_path = os.path.join(modules_path, "scripts")
sys.path.insert(0, test_path)
sys.path.insert(0, modules_path)
import mock_tables.dbconnector # required by sonic-utilities-tests
import show.main as show
class TestGearbox(TestCase):
@classmethod
def setup_class(cls):
print("SETUP")
os.environ["PATH"] += os.pathsep + scripts_path
os.environ["UTILITIES_UNIT_TESTING"] = "1"
def setUp(self):
self.runner = CliRunner()
def test_gearbox_phys_status_validation(self):
result = self.runner.invoke(show.cli.commands["gearbox"].commands["phys"].commands["status"], [])
print >> sys.stderr, result.output
expected_output = (
"PHY Id Name Firmware\n"
"-------- ------- ----------\n"
" 1 sesto-1 v0.2\n"
" 2 sesto-2 v0.3"
)
self.assertEqual(result.output.strip(), expected_output)
def test_gearbox_interfaces_status_validation(self):
result = self.runner.invoke(show.cli.commands["gearbox"].commands["interfaces"].commands["status"], [])
print >> sys.stderr, result.output
expected_output = (
"PHY Id Interface MAC Lanes MAC Lane Speed PHY Lanes PHY Lane Speed Line Lanes Line Lane Speed Oper Admin\n"
"-------- ----------- --------------- ---------------- --------------- ---------------- ------------ ----------------- ------ -------\n"
" 1 Ethernet200 200,201,202,203 25G 300,301,302,303 25G 304,305 50G down up"
)
self.assertEqual(result.output.strip(), expected_output)
@classmethod
def teardown_class(cls):
print("TEARDOWN")
os.environ["PATH"] = os.pathsep.join(os.environ["PATH"].split(os.pathsep)[:-1])
os.environ["UTILITIES_UNIT_TESTING"] = "0"