def test_execute_set_fan_speed_action():
    chassis = MockChassis()
    fan_list = chassis.get_all_fans()
    fan_list.append(MockFan())
    fan_list.append(MockFan())
    fan_info = FanInfo()
    fan_info.collect(chassis)

    from sonic_platform.thermal_actions import SetAllFanSpeedAction
    action = SetAllFanSpeedAction()
    action.speed = 99
    action.execute({'fan_info': fan_info})
    assert fan_list[0].speed == 99
    assert fan_list[1].speed == 99
Esempio n. 2
0
def test_execute_set_fan_speed_action():
    chassis = MockChassis()
    chassis.get_all_fan_drawers().append(MockFanDrawer())
    fan_list = chassis.get_all_fan_drawers()[0].get_all_fans()
    fan_list.append(MockFan())
    fan_list.append(MockFan())
    fan_info = FanInfo()
    fan_info.collect(chassis)

    Thermal.expect_cooling_level = None
    from sonic_platform.thermal_actions import SetAllFanSpeedAction
    action = SetAllFanSpeedAction()
    action.speed = 20
    action.execute({'fan_info': fan_info})
    assert Thermal.expect_cooling_level == 2
Esempio n. 3
0
def test_load_set_fan_speed_action():
    from sonic_platform.thermal_actions import SetAllFanSpeedAction
    action = SetAllFanSpeedAction()
    json_str = '{\"speed\": \"50\"}'
    json_obj = json.loads(json_str)
    action.load_from_json(json_obj)
    assert action.speed == 50

    json_str = '{\"speed\": \"-1\"}'
    json_obj = json.loads(json_str)
    with pytest.raises(ValueError):
        action.load_from_json(json_obj)

    json_str = '{\"speed\": \"101\"}'
    json_obj = json.loads(json_str)
    with pytest.raises(ValueError):
        action.load_from_json(json_obj)

    json_str = '{\"invalid\": \"101\"}'
    json_obj = json.loads(json_str)
    with pytest.raises(ValueError):
        action.load_from_json(json_obj)