forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fanshow] Display other fan status, such as Updating (sonic-net#1014)
The original fan status can be one of "OK", "Not OK", "N/A". This PR allows a new fan status "Updating". If fan status is not "true" or "false", display the status field value in CLI output.
- Loading branch information
1 parent
3e52604
commit 8934479
Showing
3 changed files
with
95 additions
and
5 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
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,38 @@ | ||
import sys | ||
import os | ||
from click.testing import CliRunner | ||
|
||
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, modules_path) | ||
|
||
import show.main as show | ||
|
||
class TestFan(object): | ||
@classmethod | ||
def setup_class(cls): | ||
print("SETUP") | ||
os.environ["PATH"] += os.pathsep + scripts_path | ||
os.environ["UTILITIES_UNIT_TESTING"] = "1" | ||
|
||
def test_show_platform_fan(self): | ||
runner = CliRunner() | ||
result = runner.invoke(show.cli.commands["platform"].commands["fan"]) | ||
print(result.output) | ||
expected = """\ | ||
Drawer LED FAN Speed Direction Presence Status Timestamp | ||
-------- ----- ----- ------- ----------- ---------- -------- ----------------- | ||
drawer1 red fan1 30% intake Present OK 20200813 01:32:30 | ||
drawer2 green fan2 50% intake Present Not OK 20200813 01:32:30 | ||
drawer3 green fan3 50% intake Present Updating 20200813 01:32:30 | ||
""" | ||
|
||
assert result.output == expected | ||
|
||
@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" | ||
|
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