Validate immediate datetime change

Validates
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-time-manager/+/31284/
This suite does not contain any test which waits for deferred updates.
Hence does not require any change wrt that.

Signed-off-by: Anusha Dathatri <adathatr@in.ibm.com>
Change-Id: I3b6fb750f153c3513714460a713d9e6a614871a4
diff --git a/redfish/managers/test_managers_bmc_time.robot b/redfish/managers/test_managers_bmc_time.robot
index b7a8c1e..dfde595 100644
--- a/redfish/managers/test_managers_bmc_time.robot
+++ b/redfish/managers/test_managers_bmc_time.robot
@@ -162,6 +162,20 @@
     Valid Value  ntp["ProtocolEnabled"]  valid_values=[True]
 
 
+Verify Immediate Consumption Of BMC Date
+    [Documentation]  Verify immediate change in BMC date time.
+    [Tags]  Verify_Immediate_Consumption_Of_BMC_Date
+    [Setup]  Run Keywords  Set Time To Manual Mode  AND
+    ...  Sleep  2s  AND  Redfish Set DateTime  valid_status_codes=[${HTTP_OK}]
+    [Teardown]  Run Keywords  FFDC On Test Case Fail  AND
+    ...  Redfish Set DateTime  valid_status_codes=[${HTTP_OK}]
+    [Template]  Set BMC Date And Verify
+
+    # host_state
+    on
+    off
+
+
 *** Keywords ***
 
 
@@ -260,4 +274,23 @@
 
     Run Keyword If  '${original_ntp["ProtocolEnabled"]}' == 'True'
     ...    Set NTP state  ${TRUE}
-    ...  ELSE  Set NTP state  ${FALSE}
\ No newline at end of file
+    ...  ELSE  Set NTP state  ${FALSE}
+
+
+Set BMC Date And Verify
+    [Documentation]  Set BMC Date Time at a given host state and verify.
+    [Arguments]  ${host_state}
+    # Description of argument(s):
+    # host_state  Host state at which date time will be updated for verification
+    #             (eg. on, off).
+
+    Run Keyword If  '${host_state}' == 'on'
+    ...    Redfish Power On  stack_mode=skip
+    ...  ELSE
+    ...    Redfish Power off  stack_mode=skip
+    ${current_date}=  Get Current Date  time_zone=UTC
+    ${new_value}=  Subtract Time From Date  ${current_date}  1 day
+    Redfish Set DateTime  ${new_value}  valid_status_codes=[${HTTP_OK}]
+    ${current_value}=  Redfish Get DateTime
+    ${time_diff}=  Subtract Date From Date  ${current_value}  ${new_value}
+    Should Be True  '${time_diff}'<='3'