Skip to content

Commit

Permalink
Added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bmridul committed Aug 18, 2023
1 parent b48f4bc commit 442887a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/chassis_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,19 @@ def test_chassis_base(self):
except NotImplementedError:
exception_raised = True

assert exception_raised
assert exception_raised

def test_sensors(self):
chassis = ChassisBase()
assert(chassis.get_num_voltage_sensors() == 0)
assert(chassis.get_all_voltage_sensors() == [])
assert(chassis.get_voltage_sensor(0) == None)
chassis._voltage_sensor_list = ["s1"]
assert(chassis.get_all_voltage_sensors() == ["s1"])
assert(chassis.get_voltage_sensor(0) == "s1")
assert(chassis.get_num_current_sensors() == 0)
assert(chassis.get_all_current_sensors() == [])
assert(chassis.get_current_sensor(0) == None)
chassis._current_sensor_list = ["s1"]
assert(chassis.get_all_current_sensors() == ["s1"])
assert(chassis.get_current_sensor(0) == "s1")
19 changes: 19 additions & 0 deletions tests/module_base_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from sonic_platform_base.module_base import ModuleBase

class TestModuleBase:

def test_sensors(self):
module = ModuleBase()
assert(module.get_num_voltage_sensors() == 0)
assert(module.get_all_voltage_sensors() == [])
assert(module.get_voltage_sensor(0) == None)
module._voltage_sensor_list = ["s1"]
assert(module.get_all_voltage_sensors() == ["s1"])
assert(module.get_voltage_sensor(0) == "s1")
assert(module.get_num_current_sensors() == 0)
assert(module.get_all_current_sensors() == [])
assert(module.get_current_sensor(0) == None)
module._current_sensor_list = ["s1"]
assert(module.get_all_current_sensors() == ["s1"])
assert(module.get_current_sensor(0) == "s1")

0 comments on commit 442887a

Please sign in to comment.