Skip to content

Commit 156eab0

Browse files
committed
Fix testing case expectation after changing the way of reading the sysfs value
Signed-off-by: Yuanzhe, Liu <[email protected]>
1 parent c711688 commit 156eab0

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

platform/mellanox/mlnx-platform-api/sonic_platform/liquid_cooling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(self, name,path):
4444
self.path = path
4545

4646
def is_leak(self):
47-
content = utils.read_int_from_file(self.path)
47+
content = utils.read_int_from_file(self.path, 0)
4848

4949
if content == 1:
5050
self.leaking = False

platform/mellanox/mlnx-platform-api/tests/test_liquid_cooling.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ def test_leakage_sensor_is_leak():
2626
# Test when file does not exist
2727
with mock.patch('os.path.exists') as mock_exists:
2828
mock_exists.return_value = False
29-
assert sensor.is_leak() is None
29+
assert sensor.is_leak() is True
3030

3131
def test_liquid_cooling_init():
32-
3332
with mock.patch('os.path.exists') as mock_exists, \
3433
mock.patch('os.path.join', side_effect=lambda *args: "/".join(args)) as mock_join, \
3534
mock.patch('glob.glob') as mock_glob:
@@ -48,5 +47,7 @@ def test_liquid_cooling_init():
4847
# Verify the number of sensors initialized
4948
assert liquid_cooling.leakage_sensors_num == 4
5049

51-
sensors = liquid_cooling.get_leak_sensor_status()
52-
assert len(sensors) == 0
50+
51+
with mock.patch.object(liquid_cooling.leakage_sensors[3], 'is_leak', return_value=False) as mock_sensor1:
52+
sensors = liquid_cooling.get_leak_sensor_status()
53+
assert len(sensors) == 3

0 commit comments

Comments
 (0)