Test Redfish date time set operation

- TC "Verify Set Time Using Redfish" added.

Change-Id: If4593e31a674b739e05d4bcab7c388196b8c7e46
Signed-off-by: Sivas SRR <sivas.srr@in.ibm.com>
diff --git a/redfish/managers/test_managers_bmc_time.robot b/redfish/managers/test_managers_bmc_time.robot
index f1932b9..9f35fa8 100644
--- a/redfish/managers/test_managers_bmc_time.robot
+++ b/redfish/managers/test_managers_bmc_time.robot
@@ -29,6 +29,25 @@
     ...  The difference between Redfish time and CLI time exceeds the allowed time difference.
 
 
+Verify Set Time Using Redfish
+    [Documentation]  Verify set time using redfish API.
+    [Tags]  Verify_Set_Time_Using_Redfish
+
+    ${old_bmc_time}=  CLI Get BMC DateTime
+    # Add 3 days to current date.
+    ${new_bmc_time}=  Add Time to Date  ${old_bmc_time}  3 Days
+    Redfish Set DateTime  ${new_bmc_time}
+    ${cli_bmc_time}=  CLI Get BMC DateTime
+    ${time_diff}=  Subtract Date From Date  ${cli_bmc_time}
+    ...  ${new_bmc_time}
+    ${time_diff}=  Evaluate  abs(${time_diff})
+    Rprint Vars   old_bmc_time  new_bmc_time  cli_bmc_time  time_diff  max_time_diff_in_seconds
+    Should Be True  ${time_diff} < ${max_time_diff_in_seconds}
+    ...  The difference between Redfish time and CLI time exceeds the allowed time difference.
+    # Setting back to old bmc time.
+    Redfish Set DateTime  ${old_bmc_time}
+
+
 *** Keywords ***
 
 Test Teardown Execution
@@ -43,3 +62,16 @@
 
     ${date_time}=  Redfish.Get Attribute  ${REDFISH_BASE_URI}Managers/bmc  DateTime
     [Return]  ${date_time}
+
+
+Redfish Set DateTime
+    [Documentation]  Set DateTime using Redfish.
+    [Arguments]  ${date_time}
+    # Description of argument(s):
+    # date_time          New time to set for BMC (eg. 2019-06-30 09:21:28).
+
+    ${payload}=  Create Dictionary  DateTime=${date_time}
+    Redfish.Patch  ${REDFISH_BASE_URI}Managers/bmc  body=&{payload}
+    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_BAD_REQUEST}]
+
+