Replaced REST with Redfish for IPMI Power Reading test cases

IPMI test cases modified:
   - Test Power Reading Via IPMI With Host Off
   - Test Power Reading Via IPMI With Host Booted

Change-Id: I7f915fdd093e86a18bbf42ac7394b29f70236e5f
Signed-off-by: Sushma M M <sushmm99@in.ibm.com>
diff --git a/ipmi/test_ipmi_sensor.robot b/ipmi/test_ipmi_sensor.robot
index e2d4c46..22ef170 100644
--- a/ipmi/test_ipmi_sensor.robot
+++ b/ipmi/test_ipmi_sensor.robot
@@ -3,6 +3,7 @@
 
 Resource          ../lib/ipmi_client.robot
 Resource          ../lib/openbmc_ffdc.robot
+Library           ../lib/ipmi_utils.py
 
 Suite Setup       Redfish.Login
 Suite Teardown    Redfish.Logout
@@ -12,6 +13,7 @@
 
 *** Variables ***
 ${allowed_temp_diff}    ${1}
+${allowed_power_diff}   ${10}
 
 
 *** Test Cases ***
@@ -95,6 +97,28 @@
     ...  msg=Ambient temperature above allowed threshold ${allowed_temp_diff}.
 
 
+Test Power Reading Via IPMI With Host Off
+    [Documentation]  Verify power reading via IPMI with host in off state
+    [Tags]  Test_Power_Reading_Via_IPMI_With_Host_Off
+
+    Redfish Power Off  stack_mode=skip
+
+    ${ipmi_reading}=  Get IPMI Power Reading
+
+    Should Be Equal  ${ipmi_reading['instantaneous_power_reading']}  0
+    ...  msg=Power reading not zero when power is off.
+
+
+Test Power Reading Via IPMI With Host Booted
+    [Documentation]  Test power reading via IPMI with host in booted state and
+    ...  verify using Redfish.
+    [Tags]  Test_Power_Reading_Via_IPMI_With_Host_Booted
+
+    IPMI Power On  stack_mode=skip
+
+    Wait Until Keyword Succeeds  2 min  30 sec  Verify Power Reading Using IPMI And Redfish
+
+
 *** Keywords ***
 
 Get Temperature Reading And Verify In Redfish
@@ -160,4 +184,28 @@
         ...  &{data}[ReadingCelsius]
         Exit For Loop If  '&{data}[MemberId]' == '${member_id}'
     END
-    [Return]  ${redfish_value}
\ No newline at end of file
+    [Return]  ${redfish_value}
+
+
+Verify Power Reading Using IPMI And Redfish
+    [Documentation]  Verify power reading using IPMI and Redfish.
+
+    # Example of power reading command output via IPMI.
+    # Instantaneous power reading:                   235 Watts
+    # Minimum during sampling period:                235 Watts
+    # Maximum during sampling period:                235 Watts
+    # Average power reading over sample period:      235 Watts
+    # IPMI timestamp:                                Thu Jan  1 00:00:00 1970
+    # Sampling period:                               00000000 Seconds.
+    # Power reading state is:                        deactivated
+
+    ${ipmi_reading}=  Get IPMI Power Reading
+
+    ${power}=  Redfish.Get Properties  /redfish/v1/Chassis/chassis/Power
+    ${redfish_reading}=  Set Variable  ${power['PowerControl'][0]['PowerConsumedWatts']}
+
+    ${ipmi_redfish_power_diff}=
+    ...  Evaluate  abs(${redfish_reading} - ${ipmi_reading['instantaneous_power_reading']})
+
+    Should Be True  ${ipmi_redfish_power_diff} <= ${allowed_power_diff}
+    ...  msg=Power reading above allowed threshold ${allowed_power_diff}.
\ No newline at end of file