Remove ODL_STREAM from VtnCoKeywords.robot
[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
9 *** Variables ***
10 &{Stream_dict}    hydrogen=${1}    stable-helium=${2}    stable-lithium=${3}    beryllium=${4}    boron=${5}    carbon=${6}    nitrogen=${7}
11
12 *** Keywords ***
13 Set_Variable_If_At_Least
14     [Arguments]    ${lower_bound}    ${value_if_true}    ${value_if_false}
15     [Documentation]    Compare ${lower_bound} to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at least ${lower_bound},
16     ...    return ${value_if_false} otherwise.
17     BuiltIn.Run_Keyword_And_Return    BuiltIn.Set_Variable_If    &{Stream_dict}[${ODL_STREAM}] >= &{Stream_dict}[${lower_bound}]    ${value_if_true}    ${value_if_false}
18
19 Set_Variable_If_At_Most
20     [Arguments]    ${upper_bound}    ${value_if_true}    ${value_if_false}
21     [Documentation]    Compare ${upper_bound} to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at most ${upper_bound},
22     ...    return ${value_if_false} otherwise.
23     BuiltIn.Run_Keyword_And_Return    BuiltIn.Set_Variable_If    &{Stream_dict}[${ODL_STREAM}] <= &{Stream_dict}[${upper_bound}]    ${value_if_true}    ${value_if_false}
24
25 Set_Variable_If_At_Least_Helium
26     [Arguments]    ${value_if_true}    ${value_if_false}
27     [Documentation]    Compare stable-helium to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at least stable-helium,
28     ...    return ${value_if_false} otherwise.
29     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Least    stable-helium    ${value_if_true}    ${value_if_false}
30
31 Set_Variable_If_At_Least_Lithium
32     [Arguments]    ${value_if_true}    ${value_if_false}
33     [Documentation]    Compare stable-lithium to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at least stable-lithium,
34     ...    return ${value_if_false} otherwise.
35     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Least    stable-lithium    ${value_if_true}    ${value_if_false}
36
37 Set_Variable_If_At_Least_Beryllium
38     [Arguments]    ${value_if_true}    ${value_if_false}
39     [Documentation]    Compare beryllium to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at least beryllium,
40     ...    return ${value_if_false} otherwise.
41     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Least    beryllium    ${value_if_true}    ${value_if_false}
42
43 Set_Variable_If_At_Least_Boron
44     [Arguments]    ${value_if_true}    ${value_if_false}
45     [Documentation]    Compare boron to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at least boron,
46     ...    return ${value_if_false} otherwise.
47     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Least    boron    ${value_if_true}    ${value_if_false}
48
49 Set_Variable_If_At_Least_Carbon
50     [Arguments]    ${value_if_true}    ${value_if_false}
51     [Documentation]    Compare carbon to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at least carbon,
52     ...    return ${value_if_false} otherwise.
53     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Least    carbon    ${value_if_true}    ${value_if_false}
54
55 Set_Variable_If_At_Most_Helium
56     [Arguments]    ${value_if_true}    ${value_if_false}
57     [Documentation]    Compare stable-helium to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at most stable-helium,
58     ...    return ${value_if_false} otherwise.
59     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Most    stable-helium    ${value_if_true}    ${value_if_false}
60
61 Set_Variable_If_At_Most_Lithium
62     [Arguments]    ${value_if_true}    ${value_if_false}
63     [Documentation]    Compare stable-lithium to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at most stable-lithium,
64     ...    return ${value_if_false} otherwise.
65     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Most    stable-lithium    ${value_if_true}    ${value_if_false}
66
67 Set_Variable_If_At_Most_Beryllium
68     [Arguments]    ${value_if_true}    ${value_if_false}
69     [Documentation]    Compare beryllium to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at most beryllium,
70     ...    return ${value_if_false} otherwise.
71     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Most    beryllium    ${value_if_true}    ${value_if_false}
72
73 Set_Variable_If_At_Most_Boron
74     [Arguments]    ${value_if_true}    ${value_if_false}
75     [Documentation]    Compare boron to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at most boron,
76     ...    return ${value_if_false} otherwise.
77     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Most    boron    ${value_if_true}    ${value_if_false}
78
79 Set_Variable_If_At_Most_Carbon
80     [Arguments]    ${value_if_true}    ${value_if_false}
81     [Documentation]    Compare carbon to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at most carbon,
82     ...    return ${value_if_false} otherwise.
83     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Most    carbon    ${value_if_true}    ${value_if_false}
84
85 Run_Keyword_If_At_Least
86     [Arguments]    ${lower_bound}    ${kw_name}    @{varargs}    &{kwargs}
87     [Documentation]    Compare ${lower_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is at least ${lower_bound},
88     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
89     BuiltIn.Run_Keyword_And_Return_If    &{Stream_dict}[${ODL_STREAM}] >= &{Stream_dict}[${lower_bound}]    ${kw_name}    @{varargs}    &{kwargs}
90
91 Run_Keyword_If_At_Least_Else
92     [Arguments]    ${lower_bound}    @{varargs}
93     [Documentation]    Compare ${lower_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is at least ${lower_bound},
94     ...    run keyword defined before ELSE statement otherwise run keyword defined after ELSE statement and return its value.
95     ${position}    Collections.Get_Index_From_List    ${varargs}    \ELSE
96     BuiltIn.Run_Keyword_If    "${position}" == "-1"    BuiltIn.Fail    Missing else statement in defined expresion
97     ${varargs_if}    Collections.Get_Slice_From_List    ${varargs}    0    ${position}
98     ${varargs_else}    Collections.Get_Slice_From_List    ${varargs}    ${position+1}
99     ${resp}    BuiltIn.Run_Keyword_If    &{Stream_dict}[${ODL_STREAM}] >= &{Stream_dict}[${lower_bound}]    @{varargs_if}
100     ...    ELSE    @{varargs_else}
101     [Return]    ${resp}
102
103 Run_Keyword_If_At_Most
104     [Arguments]    ${upper_bound}    ${kw_name}    @{varargs}    &{kwargs}
105     [Documentation]    Compare ${upper_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is at most ${upper_bound},
106     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
107     BuiltIn.Run_Keyword_And_Return_If    &{Stream_dict}[${ODL_STREAM}] <= &{Stream_dict}[${upper_bound}]    ${kw_name}    @{varargs}    &{kwargs}
108
109 Run_Keyword_If_At_Most_Else
110     [Arguments]    ${upper_bound}    @{varargs}
111     [Documentation]    Compare ${upper_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is at most ${upper_bound},
112     ...    run keyword defined before ELSE statement otherwise run keyword defined after ELSE statement and return its value.
113     ${position}    Collections.Get_Index_From_List    ${varargs}    \ELSE
114     BuiltIn.Run_Keyword_If    "${position}" == "-1"    BuiltIn.Fail    Missing else statement in defined expresion
115     ${varargs_if}    Collections.Get_Slice_From_List    ${varargs}    0    ${position}
116     ${varargs_else}    Collections.Get_Slice_From_List    ${varargs}    ${position+1}
117     ${resp}    BuiltIn.Run_Keyword_If    &{Stream_dict}[${ODL_STREAM}] <= &{Stream_dict}[${upper_bound}]    @{varargs_if}
118     ...    ELSE    @{varargs_else}
119     [Return]    ${resp}
120
121 Run_Keyword_If_More_Than
122     [Arguments]    ${lower_bound}    ${kw_name}    @{varargs}    &{kwargs}
123     [Documentation]    Compare ${lower_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is more than ${lower_bound},
124     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
125     BuiltIn.Run_Keyword_And_Return_If    &{Stream_dict}[${ODL_STREAM}] > &{Stream_dict}[${lower_bound}]    ${kw_name}    @{varargs}    &{kwargs}
126
127 Run_Keyword_If_Equals
128     [Arguments]    ${stream}    ${kw_name}    @{varargs}    &{kwargs}
129     [Documentation]    Compare ${stream} to ${ODL_STREAM} and in case ${ODL_STREAM} equals ${stream},
130     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
131     BuiltIn.Run_Keyword_And_Return_If    &{Stream_dict}[${ODL_STREAM}] == &{Stream_dict}[${stream}]    ${kw_name}    @{varargs}    &{kwargs}
132
133 Run_Keyword_If_Less_Than
134     [Arguments]    ${lower_bound}    ${kw_name}    @{varargs}    &{kwargs}
135     [Documentation]    Compare ${lower_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is less than ${lower_bound},
136     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
137     BuiltIn.Run_Keyword_And_Return_If    &{Stream_dict}[${ODL_STREAM}] < &{Stream_dict}[${lower_bound}]    ${kw_name}    @{varargs}    &{kwargs}
138
139 Run_Keyword_If_At_Least_Helium
140     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
141     [Documentation]    Compare stable-helium to ${ODL_STREAM} and in case ${ODL_STREAM} is at least stable-helium,
142     ...    run ${kw_name} @{varargs} &{kwargs} and return its value
143     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Least    stable-helium    ${kw_name}    @{varargs}    &{kwargs}
144
145 Run_Keyword_If_At_Least_Lithium
146     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
147     [Documentation]    Compare stable-lithium to ${ODL_STREAM} and in case ${ODL_STREAM} is at least stable-lithium,
148     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
149     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Least    stable-lithium    ${kw_name}    @{varargs}    &{kwargs}
150
151 Run_Keyword_If_At_Least_Beryllium
152     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
153     [Documentation]    Compare beryllium to ${ODL_STREAM} and in case ${ODL_STREAM} is at least beryllium,
154     ...    run ${kw_name} @{varargs} &{kwargs} and return its value
155     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Least    beryllium    ${kw_name}    @{varargs}    &{kwargs}
156
157 Run_Keyword_If_At_Least_Boron
158     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
159     [Documentation]    Compare boron to ${ODL_STREAM} and in case ${ODL_STREAM} is at least boron,
160     ...    run ${kw_name} @{varargs} &{kwargs} and return its value
161     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Least    boron    ${kw_name}    @{varargs}    &{kwargs}
162
163 Run_Keyword_If_At_Least_Carbon
164     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
165     [Documentation]    Compare carbon to ${ODL_STREAM} and in case ${ODL_STREAM} is at least carbon,
166     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
167     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Least    carbon    ${kw_name}    @{varargs}    &{kwargs}
168
169 Run_Keyword_If_At_Most_Helium
170     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
171     [Documentation]    Compare stable-helium to ${ODL_STREAM} and in case ${ODL_STREAM} is at most stable-helium,
172     ...    run ${kw_name} @{varargs} &{kwargs} and return its value
173     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Most    stable-helium    ${kw_name}    @{varargs}    &{kwargs}
174
175 Run_Keyword_If_At_Most_Lithium
176     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
177     [Documentation]    Compare stable-lithium to ${ODL_STREAM} and in case ${ODL_STREAM} is at most stable-lithium,
178     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
179     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Most    stable-lithium    ${kw_name}    @{varargs}    &{kwargs}
180
181 Run_Keyword_If_At_Most_Beryllium
182     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
183     [Documentation]    Compare beryllium to ${ODL_STREAM} and in case ${ODL_STREAM} is at most beryllium,
184     ...    run ${kw_name} @{varargs} &{kwargs} and return its value
185     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Most    beryllium    ${kw_name}    @{varargs}    &{kwargs}
186
187 Run_Keyword_If_At_Most_Boron
188     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
189     [Documentation]    Compare boron to ${ODL_STREAM} and in case ${ODL_STREAM} is at most boron,
190     ...    run ${kw_name} @{varargs} &{kwargs} and return its value
191     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Most    boron    ${kw_name}    @{varargs}    &{kwargs}
192
193 Run_Keyword_If_At_Most_Carbon
194     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
195     [Documentation]    Compare carbon to ${ODL_STREAM} and in case ${ODL_STREAM} is at most carbon,
196     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
197     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Most    carbon    ${kw_name}    @{varargs}    &{kwargs}
198
199 Run_Keyword_If_More_Than_Helium
200     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
201     [Documentation]    Compare stable-helium to ${ODL_STREAM} and in case ${ODL_STREAM} is more than stable-helium,
202     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
203     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_More_Than    stable-helium    ${kw_name}    @{varargs}    &{kwargs}
204
205 Run_Keyword_If_Less_Than_Helium
206     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
207     [Documentation]    Compare stable-helium to ${ODL_STREAM} and in case ${ODL_STREAM} is less than stable-helium,
208     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
209     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_Less_Than    stable-helium    ${kw_name}    @{varargs}    &{kwargs}
210
211 Run_Keyword_If_More_Than_Lithium
212     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
213     [Documentation]    Compare stable-lithium to ${ODL_STREAM} and in case ${ODL_STREAM} is more than stable-lithium,
214     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
215     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_More_Than    stable-lithium    ${kw_name}    @{varargs}    &{kwargs}
216
217 Run_Keyword_If_Less_Than_Lithium
218     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
219     [Documentation]    Compare stable-lithium to ${ODL_STREAM} and in case ${ODL_STREAM} is less than stable-lithium,
220     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
221     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_Less_Than    stable-lithium    ${kw_name}    @{varargs}    &{kwargs}
222
223 Run_Keyword_If_More_Than_Beryllium
224     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
225     [Documentation]    Compare beryllium to ${ODL_STREAM} and in case ${ODL_STREAM} is more than beryllium,
226     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
227     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_More_Than    beryllium    ${kw_name}    @{varargs}    &{kwargs}
228
229 Run_Keyword_If_Less_Than_Beryllium
230     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
231     [Documentation]    Compare beryllium to ${ODL_STREAM} and in case ${ODL_STREAM} is less than beryllium,
232     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
233     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_Less_Than    beryllium    ${kw_name}    @{varargs}    &{kwargs}
234
235 Run_Keyword_If_More_Than_Boron
236     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
237     [Documentation]    Compare boron to ${ODL_STREAM} and in case ${ODL_STREAM} is more than boron,
238     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
239     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_More_Than    boron    ${kw_name}    @{varargs}    &{kwargs}
240
241 Run_Keyword_If_Less_Than_Boron
242     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
243     [Documentation]    Compare boron to ${ODL_STREAM} and in case ${ODL_STREAM} is less than boron,
244     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
245     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_Less_Than    boron    ${kw_name}    @{varargs}    &{kwargs}
246
247 Run_Keyword_If_More_Than_Carbon
248     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
249     [Documentation]    Compare carbon to ${ODL_STREAM} and in case ${ODL_STREAM} is more than carbon,
250     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
251     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_More_Than    carbon    ${kw_name}    @{varargs}    &{kwargs}
252
253 Run_Keyword_If_Less_Than_Carbon
254     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
255     [Documentation]    Compare carbon to ${ODL_STREAM} and in case ${ODL_STREAM} is less than carbon,
256     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
257     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_Less_Than    carbon    ${kw_name}    @{varargs}    &{kwargs}