예제 #1
0
    def test_get_temperature(self):
        from sonic_platform.thermal import Thermal
        from sonic_platform import utils
        thermal = Thermal('test', 'temp_file', None, None, 1)
        utils.read_float_from_file = mock.MagicMock(return_value=35727)
        assert thermal.get_temperature() == 35.727

        utils.read_float_from_file = mock.MagicMock(return_value=0.0)
        assert thermal.get_temperature() is None

        utils.read_float_from_file = mock.MagicMock(return_value=None)
        assert thermal.get_temperature() is None
예제 #2
0
    def test_get_high_threshold(self):
        from sonic_platform.thermal import Thermal
        from sonic_platform import utils
        thermal = Thermal('test', None, None, None, 1)
        assert thermal.get_high_threshold() is None

        thermal.high_threshold = 'high_th_file'
        utils.read_float_from_file = mock.MagicMock(return_value=25833)
        assert thermal.get_temperature() == 25.833

        utils.read_float_from_file = mock.MagicMock(return_value=0.0)
        assert thermal.get_temperature() is None

        utils.read_float_from_file = mock.MagicMock(return_value=None)
        assert thermal.get_temperature() is None