From 85c7cb01c576e95e0f7fcff2ad2c4a9038600f81 Mon Sep 17 00:00:00 2001 From: Petro Bratash Date: Wed, 18 Nov 2020 01:19:58 -0800 Subject: [PATCH] Fix test_updater_thermal_check_min_max() Signed-off-by: Petro Bratash --- sonic-thermalctld/tests/mock_platform.py | 5 +++-- sonic-thermalctld/tests/test_thermalctld.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sonic-thermalctld/tests/mock_platform.py b/sonic-thermalctld/tests/mock_platform.py index 8954cddb6..223d0c64e 100644 --- a/sonic-thermalctld/tests/mock_platform.py +++ b/sonic-thermalctld/tests/mock_platform.py @@ -112,9 +112,10 @@ def set_status_led(self, value): class MockThermal(MockDevice): - def __init__(self): + def __init__(self, index = None): MockDevice.__init__(self) self.name = None + self.name = 'Thermal {}'.format(index) if index != None else None self.temperature = 2 self.minimum_temperature = 1 self.maximum_temperature = 5 @@ -122,7 +123,7 @@ def __init__(self): self.low_threshold = 1 self.high_critical_threshold = 4 self.low_critical_threshold = 0 - + def get_name(self): return self.name diff --git a/sonic-thermalctld/tests/test_thermalctld.py b/sonic-thermalctld/tests/test_thermalctld.py index d327bf8b9..d3779fb09 100644 --- a/sonic-thermalctld/tests/test_thermalctld.py +++ b/sonic-thermalctld/tests/test_thermalctld.py @@ -329,7 +329,7 @@ def test_updater_thermal_check_chassis_table(): def test_updater_thermal_check_min_max(): chassis = MockChassis() - thermal = MockThermal() + thermal = MockThermal(1) chassis.get_all_thermals().append(thermal) chassis.set_modular_chassis(True) @@ -337,6 +337,6 @@ def test_updater_thermal_check_min_max(): temperature_updater = TemperatureUpdater(SYSLOG_IDENTIFIER, chassis) temperature_updater.update() - slot_dict = temperature_updater.chassis_table.get('Thermal 1') + slot_dict = temperature_updater.chassis_table.get(thermal.get_name()) assert slot_dict['minimum_temperature'] == str(thermal.get_minimum_recorded()) assert slot_dict['maximum_temperature'] == str(thermal.get_maximum_recorded())