Update alternate fan settings with new fan setting options

Resolves openbmc/openbmc-test-automation#1960

Signed-off-by: Marissa Garza <garzam@us.ibm.com>
Change-Id: I2442df58d4f1ca26d3da0b2bc2a0179ae31d29d3
diff --git a/data/variables.py b/data/variables.py
index f62dd48..231d08f 100755
--- a/data/variables.py
+++ b/data/variables.py
@@ -20,6 +20,8 @@
 SNMP_MANAGER_URI = NETWORK_MANAGER + 'snmp/manager/'
 # Sensors base variables.
 SENSORS_URI = OPENBMC_BASE_URI + 'sensors/'
+# Thermal Control base variables
+THERMAL_CONTROL_URI = CONTROL_URI + 'thermal/0'
 
 # State Manager base variables
 BMC_REBOOT_TRANS = 'xyz.openbmc_project.State.BMC.Transition.Reboot'
diff --git a/redfish/systems/test_alternate_fan_settings.robot b/redfish/systems/test_alternate_fan_settings.robot
new file mode 100755
index 0000000..2688680
--- /dev/null
+++ b/redfish/systems/test_alternate_fan_settings.robot
@@ -0,0 +1,152 @@
+*** Settings ***
+
+Documentation  Test Suite for Suppported Fan Modules.
+
+Resource         ../../lib/rest_client.robot
+Resource         ../../lib/bmc_redfish_resource.robot
+Resource         ../../lib/bmc_redfish_utils.robot
+Resource         ../../lib/openbmc_ffdc.robot
+Resource         ../../lib/resource.robot
+Resource         ../../lib/boot_utils.robot
+Library          ../../lib/gen_robot_valid.py
+Library          ../../lib/gen_robot_keyword.py
+
+Suite Setup      Suite Setup Execution
+Suite Teardown   Suite Teardown Execution
+Test Setup       Printn
+Test Teardown    Test Teardown Execution
+
+
+*** Variables ***
+
+@{VALID_MODE_VALUES}   DEFAULT  CUSTOM  HEAVY_IO  MAX_BASE_FAN_FLOOR
+
+
+*** Test Cases ***
+
+Verify Current Fan Thermal Mode
+    [Documentation]  Check current thermal fan mode is a valid mode value.
+    [Tags]  Verify_Current_Fan_Thermal_Mode
+
+    # Example:
+    #  /xyz/openbmc_project/control/thermal/0
+    #
+    # Response code:200, Content: {
+    # "data": {
+    #         "Current": "DEFAULT",
+    #         "Supported": [
+    #           "DEFAULT",
+    #           "CUSTOM",
+    #           "HEAVY_IO",
+    #           "MAX_BASE_FAN_FLOOR"
+    #         },
+    #         },
+    # "message": "200 OK",
+    # "status": "ok"
+    # }
+
+    ${current}=  Read Attribute  ${THERMAL_CONTROL_URI}  Current
+    Rprint Vars  current
+
+    Valid Value  current  valid_values=${VALID_MODE_VALUES}
+
+
+Verify Supported Fan Thermal Modes Available
+    [Documentation]  Check supported fan thermal modes are valid mode values.
+    [Tags]  Verify_Supported_Fan_Thermal_Modes_Available
+
+    ${supported}=  Read Attribute  ${THERMAL_CONTROL_URI}  Supported
+    Rprint Vars  supported
+
+    Valid List  supported  valid_values=${VALID_MODE_VALUES}
+
+
+Verify Supported Fan Thermal Modes Switch At Standby
+    [Documentation]  Check that supported modes are set successfully at standby.
+    [Tags]  Verify_Supported_Fan_Thermal_Modes_Switch_At_Standby
+    [Template]  Set and Verify Thermal Mode Switches
+
+    # pre_req_state      thermal_mode_type
+    Off                  DEFAULT
+    Off                  CUSTOM
+    Off                  HEAVY_IO
+    Off                  MAX_BASE_FAN_FLOOR
+
+
+Verify Supported Fan Thermal Modes Switch At Runtime
+    [Documentation]  Check that supported modes are set successfully at runtime.
+    [Tags]  Verify_Supported_Fan_Thermal_Modes_Switch_At_Runtime
+    [Template]  Set and Verify Thermal Mode Switches
+
+    # pre_req_state      thermal_mode
+    On                   DEFAULT
+    On                   CUSTOM
+    On                   HEAVY_IO
+    On                   MAX_BASE_FAN_FLOOR
+
+
+Verify Supported Fan Thermal Mode Remains Set After IPL
+    [Documentation]  Check that supported modes remain set at runtime.
+    [Tags]  Verify_Supported_Fan_Thermal_Mode_Remains_Set_After_IPL
+    [Template]  Set and Verify Thermal Mode After IPL
+
+    # pre_req_state      thermal_mode_type
+    Off                  DEFAULT
+    Off                  CUSTOM
+    Off                  HEAVY_IO
+    Off                  MAX_BASE_FAN_FLOOR
+
+
+*** Keywords ***
+
+Set and Verify Thermal Mode Switches
+    [Documentation]  Verify the thermal mode switches successfully at standby or runtime.
+    [Arguments]  ${pre_req_state}  ${thermal_mode}
+
+    # Description of Arguments(s):
+    # thermal_mode       Read the supported thermal mode (e.g. "CUSTOM")
+    # pre_req_state      Set the state of the host to Standby or Runtime (e.g. "Running")
+
+    Run Key U  Redfish Power ${pre_req_state} \ stack_mode=skip \ quiet=1
+    Redfish.Login
+
+    ${mode}=  Redfish.Put  ${THERMAL_CONTROL_URI}/attr/Current  body={"data": "${thermal_mode}"}
+
+    ${current}=  Read Attribute  ${THERMAL_CONTROL_URI}  Current
+    Should Be Equal As Strings  ${thermal_mode}  ${current}
+    ...  msg=The thermal mode does not match the current fan mode.
+    Rprint Vars  current
+
+
+Set and Verify Thermal Mode After IPL
+    [Documentation]  Verify the thermal mode remains set at runtime.
+    [Arguments]  ${pre_req_state}  ${thermal_mode}
+
+    Set and Verify Thermal Mode Switches  ${pre_req_state}  ${thermal_mode}
+
+    Run Key U  Redfish Power On \ stack_mode=normal \ quiet=1
+    Redfish.Login
+
+    ${current}=  Read Attribute  ${THERMAL_CONTROL_URI}  Current
+    Should Be Equal As Strings  ${thermal_mode}  ${current}
+    ...  msg=The current thermal fan mode switched successfully.
+    Rprint Vars  current
+
+
+Suite Teardown Execution
+    [Documentation]  Do the post suite teardown.
+
+    Redfish.Logout
+
+
+Suite Setup Execution
+    [Documentation]  Do test case setup tasks.
+
+    Printn
+    Redfish.Login
+
+
+Test Teardown Execution
+    [Documentation]  Do the post test teardown.
+
+    FFDC On Test Case Fail