Fix validations HTTP error
[integration/test.git] / csit / libraries / CompareStream.robot
index e390feb41f226db8642d9dbdbbad0bf1655b14b6..aaa283ee531b9dc38a6cd8ea1bc1ea43a014fc62 100644 (file)
@@ -156,6 +156,20 @@ Run_Keyword_If_Equals
     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
     BuiltIn.Run_Keyword_And_Return_If    &{Stream_dict}[${ODL_STREAM}] == &{Stream_dict}[${stream}]    ${kw_name}    @{varargs}    &{kwargs}
 
+Run_Keyword_If_Equals_Else
+    [Arguments]    ${stream}    @{varargs}
+    [Documentation]    Compare ${stream} to ${ODL_STREAM} and in case ${ODL_STREAM} equals ${stream},
+    ...    run keyword defined before ELSE statement otherwise run keyword defined after ELSE statement and return its value.
+    ${position}    Collections.Get_Index_From_List    ${varargs}    \ELSE
+    BuiltIn.Run_Keyword_If    "${position}" == "-1"    BuiltIn.Fail    Missing else statement in defined expresion
+    ${varargs_if}    Collections.Get_Slice_From_List    ${varargs}    0    ${position}
+    ${varargs_else}    Collections.Get_Slice_From_List    ${varargs}    ${position+1}
+    ${args_if}    ${kwargs_if}    CompareStream__Convert_Input    @{varargs_if}
+    ${args_else}    ${kwargs_else}    CompareStream__Convert_Input    @{varargs_else}
+    ${resp}    BuiltIn.Run_Keyword_If    &{Stream_dict}[${ODL_STREAM}] == &{Stream_dict}[${stream}]    @{args_if}    &{kwargs_if}
+    ...    ELSE    @{args_else}    &{kwargs_else}
+    [Return]    ${resp}
+
 Run_Keyword_If_Less_Than
     [Arguments]    ${lower_bound}    ${kw_name}    @{varargs}    &{kwargs}
     [Documentation]    Compare ${lower_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is less than ${lower_bound},