Reading the types of power sensor voltages

Signed-off-by: Marissa Garza <garzam@us.ibm.com>
Change-Id: I7a70585265f4e469e03596cacd445855bb66b6e2
diff --git a/data/variables.py b/data/variables.py
index eff1b19..129d1a8 100755
--- a/data/variables.py
+++ b/data/variables.py
@@ -157,8 +157,10 @@
 REDFISH_LDAP_CERTIFICATE_URI = REDFISH_BASE_URI + REDFISH_LDAP_CERTIFICATE
 REDFISH_CA_CERTIFICATE = 'Managers/bmc/Truststore/Certificates'
 REDFISH_CA_CERTIFICATE_URI = REDFISH_BASE_URI + REDFISH_CA_CERTIFICATE
-REDFISH_CHASSIS_THERMAL = 'Chassis/chassis/Thermal'
+REDFISH_CHASSIS_THERMAL = 'Chassis/chassis/Thermal/'
 REDFISH_CHASSIS_THERMAL_URI = REDFISH_BASE_URI + REDFISH_CHASSIS_THERMAL
+REDFISH_CHASSIS_POWER = 'Chassis/chassis/Power/'
+REDFISH_CHASSIS_POWER_URI = REDFISH_BASE_URI + REDFISH_CHASSIS_POWER
 
 # Boot options and URI variables.
 POWER_ON = 'On'
diff --git a/redfish/systems/test_power_voltage_readings.robot b/redfish/systems/test_power_voltage_readings.robot
new file mode 100755
index 0000000..7922418
--- /dev/null
+++ b/redfish/systems/test_power_voltage_readings.robot
@@ -0,0 +1,76 @@
+*** Settings ***
+Documentation       Getting the systems power sensor readings for voltages.
+
+Resource            ../../lib/bmc_redfish_resource.robot
+Resource            ../../lib/bmc_redfish_utils.robot
+Resource            ../../lib/openbmc_ffdc.robot
+Library             ../../lib/gen_robot_valid.py
+
+Suite Setup         Suite Setup Execution
+Suite Teardown      Suite Teardown Execution
+Test Setup          Printn
+Test Teardown       Test Teardown Execution
+
+
+*** Test Cases ***
+
+Get Power Sensor Voltage Records
+    [Documentation]  Get the power voltage records.
+    [Tags]  Get_Power_Sensor_Voltage_Records
+    [Template]  Get Voltage Records and Verify
+
+    # record_type   reading_type
+    Voltages        ReadingVolts
+
+
+*** Keywords ***
+
+Get Voltage Records and Verify
+    [Documentation]  Get the power records for voltages.
+    [Arguments]  ${record_type}  ${reading_type}
+
+    # Description of Arguments(s):
+    # record_type    The sensor record type (e.g. "Voltages")
+    # reading_type   The power voltage readings (e.g. "ReadingVolts")
+
+    # A valid record will have "State" key "Enabled" and "Health" key "OK"
+    ${records}=  Redfish.Get Attribute
+    ...  ${REDFISH_CHASSIS_POWER_URI}  ${record_type}
+
+    ${num_records}=  Get Length  ${records}
+    Rprint Vars  num_records  records  fmt=terse
+
+    ${invalid_records}=  Filter Struct  ${records}
+    ...  [('Health', '^OK$'), ('State', '^Enabled$'), ('${reading_type}', '')]  regex=1  invert=1
+    ${num_invalid_records}=  Get Length  ${invalid_records}
+
+    Run Keyword If  ${num_invalid_records} > ${0}
+    ...  Rprint Vars  num_invalid_records  invalid_records  fmt=terse
+    Rvalid Value  num_invalid_records  valid_values=[0]
+
+    ${invalid_records}=  Evaluate
+    ...  [x for x in ${records} if not x['LowerThresholdNonCritical'] <= x['ReadingVolts'] <= x['UpperThresholdNonCritical']]
+
+    ${num_invalid_records}=  Get Length  ${invalid_records}
+    Run Keyword If  ${num_invalid_records} > ${0}
+    ...  Rprint Vars  num_invalid_records  invalid_records  fmt=terse
+    Rvalid Value  num_invalid_records  valid_values=[0]
+
+
+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