Cleanup unsupported releases from CompareStream
[integration/test.git] / csit / libraries / CompareStream.robot
1 *** Settings ***
2 Documentation     This Resource contains list of Keywords Set_Variable_If_At_Least*, Set_Variable_If_At_Most,
3 ...               Run_Keyword_If_At_Least*, Run_Keyword_If_At_Most*,
4 ...               Run_Keyword_If_More_Than*, Run_Keyword_If_Less_Than*,
5 ...               for comparison ${ODL_STREAM} to the given ${lower_bound},
6 ...               in order to replace ad-hoc conditional execution in suites.
7 Library           Collections
8 Library           String
9
10 *** Variables ***
11 &{Stream_dict}    carbon=${6}    nitrogen=${7}    oxygen=${8}
12
13 *** Keywords ***
14 Set_Variable_If_At_Least
15     [Arguments]    ${lower_bound}    ${value_if_true}    ${value_if_false}
16     [Documentation]    Compare ${lower_bound} to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at least ${lower_bound},
17     ...    return ${value_if_false} otherwise.
18     BuiltIn.Run_Keyword_And_Return    BuiltIn.Set_Variable_If    &{Stream_dict}[${ODL_STREAM}] >= &{Stream_dict}[${lower_bound}]    ${value_if_true}    ${value_if_false}
19
20 Set_Variable_If_At_Most
21     [Arguments]    ${upper_bound}    ${value_if_true}    ${value_if_false}
22     [Documentation]    Compare ${upper_bound} to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at most ${upper_bound},
23     ...    return ${value_if_false} otherwise.
24     BuiltIn.Run_Keyword_And_Return    BuiltIn.Set_Variable_If    &{Stream_dict}[${ODL_STREAM}] <= &{Stream_dict}[${upper_bound}]    ${value_if_true}    ${value_if_false}
25
26 Set_Variable_If_At_Least_Carbon
27     [Arguments]    ${value_if_true}    ${value_if_false}
28     [Documentation]    Compare carbon to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at least carbon,
29     ...    return ${value_if_false} otherwise.
30     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Least    carbon    ${value_if_true}    ${value_if_false}
31
32 Set_Variable_If_At_Least_Nitrogen
33     [Arguments]    ${value_if_true}    ${value_if_false}
34     [Documentation]    Compare nitrogen to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at least nitrogen,
35     ...    return ${value_if_false} otherwise.
36     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Least    nitrogen    ${value_if_true}    ${value_if_false}
37
38 Set_Variable_If_At_Most_Carbon
39     [Arguments]    ${value_if_true}    ${value_if_false}
40     [Documentation]    Compare carbon to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at most carbon,
41     ...    return ${value_if_false} otherwise.
42     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Most    carbon    ${value_if_true}    ${value_if_false}
43
44 Set_Variable_If_At_Most_Nitrogen
45     [Arguments]    ${value_if_true}    ${value_if_false}
46     [Documentation]    Compare nitrogen to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at most nitrogen,
47     ...    return ${value_if_false} otherwise.
48     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Most    nitrogen    ${value_if_true}    ${value_if_false}
49
50 CompareStream__Convert_Input
51     [Arguments]    @{arguments}
52     [Documentation]    Splits arguments into args and kwargs is used in Run_Keyword_If_At_Least_Else and Run_Keyword_If_At_Most_Else.
53     ...    The problem is, when the string contains =, but it is not a named argument (name=value). There can be many values containing =, but
54     ...    for sure it is present in xmls. If the string starts with "<" it will be treated as it is xml and splitting for
55     ...    name and value will not be executed.
56     ...    If named argument is passed into this kw, only string data are supported e.g. name=string. Complex variables such as lists or dictionaries
57     ...    are not supported.
58     ${args}    BuiltIn.Create_List
59     ${kwargs}    BuiltIn.Create_Dictionary
60     : FOR    ${arg}    IN    @{arguments}
61     \    ${arg}    BuiltIn.Convert_To_String    ${arg}
62     \    ${removed}    String.Remove_String    ${arg}    \n    ${Space}    \t
63     \    ...    \r
64     \    ${splitted}    BuiltIn.Run_Keyword_If    "${removed[0]}" == "<"    BuiltIn.Create List    ${arg}
65     \    ...    ELSE    String.Split_String    ${arg}    separator==    max_split=1
66     \    ${len}    BuiltIn.Get_Length    ${splitted}
67     \    Run Keyword If    ${len}==1    Collections.Append_To_List    ${args}    @{splitted}[0]
68     \    ...    ELSE    Collections.Set_To_Dictionary    ${kwargs}    @{splitted}
69     BuiltIn.Return_From_Keyword    ${args}    ${kwargs}
70
71 Run_Keyword_If_At_Least
72     [Arguments]    ${lower_bound}    ${kw_name}    @{varargs}    &{kwargs}
73     [Documentation]    Compare ${lower_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is at least ${lower_bound},
74     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
75     BuiltIn.Run_Keyword_And_Return_If    &{Stream_dict}[${ODL_STREAM}] >= &{Stream_dict}[${lower_bound}]    ${kw_name}    @{varargs}    &{kwargs}
76
77 Run_Keyword_If_At_Least_Else
78     [Arguments]    ${lower_bound}    @{varargs}
79     [Documentation]    Compare ${lower_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is at least ${lower_bound},
80     ...    run keyword defined before ELSE statement otherwise run keyword defined after ELSE statement and return its value.
81     ${position}    Collections.Get_Index_From_List    ${varargs}    \ELSE
82     BuiltIn.Run_Keyword_If    "${position}" == "-1"    BuiltIn.Fail    Missing else statement in defined expresion
83     ${varargs_if}    Collections.Get_Slice_From_List    ${varargs}    0    ${position}
84     ${varargs_else}    Collections.Get_Slice_From_List    ${varargs}    ${position+1}
85     ${args_if}    ${kwargs_if}    CompareStream__Convert_Input    @{varargs_if}
86     ${args_else}    ${kwargs_else}    CompareStream__Convert_Input    @{varargs_else}
87     ${resp}    BuiltIn.Run_Keyword_If    &{Stream_dict}[${ODL_STREAM}] >= &{Stream_dict}[${lower_bound}]    @{args_if}    &{kwargs_if}
88     ...    ELSE    @{args_else}    &{kwargs_else}
89     [Return]    ${resp}
90
91 Run_Keyword_If_At_Most
92     [Arguments]    ${upper_bound}    ${kw_name}    @{varargs}    &{kwargs}
93     [Documentation]    Compare ${upper_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is at most ${upper_bound},
94     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
95     BuiltIn.Run_Keyword_And_Return_If    &{Stream_dict}[${ODL_STREAM}] <= &{Stream_dict}[${upper_bound}]    ${kw_name}    @{varargs}    &{kwargs}
96
97 Run_Keyword_If_At_Most_Else
98     [Arguments]    ${upper_bound}    @{varargs}
99     [Documentation]    Compare ${upper_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is at most ${upper_bound},
100     ...    run keyword defined before ELSE statement otherwise run keyword defined after ELSE statement and return its value.
101     ${position}    Collections.Get_Index_From_List    ${varargs}    \ELSE
102     BuiltIn.Run_Keyword_If    "${position}" == "-1"    BuiltIn.Fail    Missing else statement in defined expresion
103     ${varargs_if}    Collections.Get_Slice_From_List    ${varargs}    0    ${position}
104     ${varargs_else}    Collections.Get_Slice_From_List    ${varargs}    ${position+1}
105     ${args_if}    ${kwargs_if}    CompareStream__Convert_Input    @{varargs_if}
106     ${args_else}    ${kwargs_else}    CompareStream__Convert_Input    @{varargs_else}
107     ${resp}    BuiltIn.Run_Keyword_If    &{Stream_dict}[${ODL_STREAM}] >= &{Stream_dict}[${lower_bound}]    @{args_if}    &{kwargs_if}
108     ...    ELSE    @{args_else}    &{kwargs_else}
109     [Return]    ${resp}
110
111 Run_Keyword_If_More_Than
112     [Arguments]    ${lower_bound}    ${kw_name}    @{varargs}    &{kwargs}
113     [Documentation]    Compare ${lower_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is more than ${lower_bound},
114     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
115     BuiltIn.Run_Keyword_And_Return_If    &{Stream_dict}[${ODL_STREAM}] > &{Stream_dict}[${lower_bound}]    ${kw_name}    @{varargs}    &{kwargs}
116
117 Run_Keyword_If_Equals
118     [Arguments]    ${stream}    ${kw_name}    @{varargs}    &{kwargs}
119     [Documentation]    Compare ${stream} to ${ODL_STREAM} and in case ${ODL_STREAM} equals ${stream},
120     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
121     BuiltIn.Run_Keyword_And_Return_If    &{Stream_dict}[${ODL_STREAM}] == &{Stream_dict}[${stream}]    ${kw_name}    @{varargs}    &{kwargs}
122
123 Run_Keyword_If_Less_Than
124     [Arguments]    ${lower_bound}    ${kw_name}    @{varargs}    &{kwargs}
125     [Documentation]    Compare ${lower_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is less than ${lower_bound},
126     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
127     BuiltIn.Run_Keyword_And_Return_If    &{Stream_dict}[${ODL_STREAM}] < &{Stream_dict}[${lower_bound}]    ${kw_name}    @{varargs}    &{kwargs}
128
129 Run_Keyword_If_At_Least_Carbon
130     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
131     [Documentation]    Compare carbon to ${ODL_STREAM} and in case ${ODL_STREAM} is at least carbon,
132     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
133     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Least    carbon    ${kw_name}    @{varargs}    &{kwargs}
134
135 Run_Keyword_If_At_Least_Nitrogen
136     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
137     [Documentation]    Compare nitrogen to ${ODL_STREAM} and in case ${ODL_STREAM} is at least nitrogen,
138     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
139     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Least    nitrogen    ${kw_name}    @{varargs}    &{kwargs}
140
141 Run_Keyword_If_At_Most_Carbon
142     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
143     [Documentation]    Compare carbon to ${ODL_STREAM} and in case ${ODL_STREAM} is at most carbon,
144     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
145     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Most    carbon    ${kw_name}    @{varargs}    &{kwargs}
146
147 Run_Keyword_If_At_Most_Nitrogen
148     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
149     [Documentation]    Compare nitrogen to ${ODL_STREAM} and in case ${ODL_STREAM} is at most nitrogen,
150     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
151     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Most    nitrogen    ${kw_name}    @{varargs}    &{kwargs}
152
153 Run_Keyword_If_More_Than_Carbon
154     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
155     [Documentation]    Compare carbon to ${ODL_STREAM} and in case ${ODL_STREAM} is more than carbon,
156     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
157     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_More_Than    carbon    ${kw_name}    @{varargs}    &{kwargs}
158
159 Run_Keyword_If_Less_Than_Carbon
160     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
161     [Documentation]    Compare carbon to ${ODL_STREAM} and in case ${ODL_STREAM} is less than carbon,
162     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
163     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_Less_Than    carbon    ${kw_name}    @{varargs}    &{kwargs}
164
165 Run_Keyword_If_More_Than_Nitrogen
166     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
167     [Documentation]    Compare nitrogen to ${ODL_STREAM} and in case ${ODL_STREAM} is more than nitrogen,
168     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
169     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_More_Than    nitrogen    ${kw_name}    @{varargs}    &{kwargs}
170
171 Run_Keyword_If_Less_Than_Nitrogen
172     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
173     [Documentation]    Compare nitrogen to ${ODL_STREAM} and in case ${ODL_STREAM} is less than nitrogen,
174     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
175     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_Less_Than    nitrogen    ${kw_name}    @{varargs}    &{kwargs}