Add fluorine keywords to CompareStream lib
[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}    fluorine=${9}
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_Least_Oxygen
39     [Arguments]    ${value_if_true}    ${value_if_false}
40     [Documentation]    Compare oxygen to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at least oxygen,
41     ...    return ${value_if_false} otherwise.
42     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Least    oxygen    ${value_if_true}    ${value_if_false}
43
44 Set_Variable_If_At_Least_Fluorine
45     [Arguments]    ${value_if_true}    ${value_if_false}
46     [Documentation]    Compare fluorine to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at least fluorine,
47     ...    return ${value_if_false} otherwise.
48     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Least    fluorine    ${value_if_true}    ${value_if_false}
49
50 Set_Variable_If_At_Most_Carbon
51     [Arguments]    ${value_if_true}    ${value_if_false}
52     [Documentation]    Compare carbon to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at most carbon,
53     ...    return ${value_if_false} otherwise.
54     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Most    carbon    ${value_if_true}    ${value_if_false}
55
56 Set_Variable_If_At_Most_Nitrogen
57     [Arguments]    ${value_if_true}    ${value_if_false}
58     [Documentation]    Compare nitrogen to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at most nitrogen,
59     ...    return ${value_if_false} otherwise.
60     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Most    nitrogen    ${value_if_true}    ${value_if_false}
61
62 Set_Variable_If_At_Most_Oxygen
63     [Arguments]    ${value_if_true}    ${value_if_false}
64     [Documentation]    Compare oxygen to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at most oxygen,
65     ...    return ${value_if_false} otherwise.
66     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Most    oxygen    ${value_if_true}    ${value_if_false}
67
68 Set_Variable_If_At_Most_Fluorine
69     [Arguments]    ${value_if_true}    ${value_if_false}
70     [Documentation]    Compare fluorine to ${ODL_STREAM} and return ${value_if_true} if ${ODL_STREAM} is at most fluorine,
71     ...    return ${value_if_false} otherwise.
72     BuiltIn.Run_Keyword_And_Return    Set_Variable_If_At_Most    fluorine    ${value_if_true}    ${value_if_false}
73
74 CompareStream__Convert_Input
75     [Arguments]    @{arguments}
76     [Documentation]    Splits arguments into args and kwargs is used in Run_Keyword_If_At_Least_Else and Run_Keyword_If_At_Most_Else.
77     ...    The problem is, when the string contains =, but it is not a named argument (name=value). There can be many values containing =, but
78     ...    for sure it is present in xmls. If the string starts with "<" it will be treated as it is xml and splitting for
79     ...    name and value will not be executed.
80     ...    If named argument is passed into this kw, only string data are supported e.g. name=string. Complex variables such as lists or dictionaries
81     ...    are not supported.
82     ${args}    BuiltIn.Create_List
83     ${kwargs}    BuiltIn.Create_Dictionary
84     : FOR    ${arg}    IN    @{arguments}
85     \    ${arg}    BuiltIn.Convert_To_String    ${arg}
86     \    ${removed}    String.Remove_String    ${arg}    \n    ${Space}    \t
87     \    ...    \r
88     \    ${splitted}    BuiltIn.Run_Keyword_If    "${removed[0]}" == "<"    BuiltIn.Create List    ${arg}
89     \    ...    ELSE    String.Split_String    ${arg}    separator==    max_split=1
90     \    ${len}    BuiltIn.Get_Length    ${splitted}
91     \    Run Keyword If    ${len}==1    Collections.Append_To_List    ${args}    @{splitted}[0]
92     \    ...    ELSE    Collections.Set_To_Dictionary    ${kwargs}    @{splitted}
93     BuiltIn.Return_From_Keyword    ${args}    ${kwargs}
94
95 Run_Keyword_If_At_Least
96     [Arguments]    ${lower_bound}    ${kw_name}    @{varargs}    &{kwargs}
97     [Documentation]    Compare ${lower_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is at least ${lower_bound},
98     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
99     BuiltIn.Run_Keyword_And_Return_If    &{Stream_dict}[${ODL_STREAM}] >= &{Stream_dict}[${lower_bound}]    ${kw_name}    @{varargs}    &{kwargs}
100
101 Run_Keyword_If_At_Least_Else
102     [Arguments]    ${lower_bound}    @{varargs}
103     [Documentation]    Compare ${lower_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is at least ${lower_bound},
104     ...    run keyword defined before ELSE statement otherwise run keyword defined after ELSE statement and return its value.
105     ${position}    Collections.Get_Index_From_List    ${varargs}    \ELSE
106     BuiltIn.Run_Keyword_If    "${position}" == "-1"    BuiltIn.Fail    Missing else statement in defined expresion
107     ${varargs_if}    Collections.Get_Slice_From_List    ${varargs}    0    ${position}
108     ${varargs_else}    Collections.Get_Slice_From_List    ${varargs}    ${position+1}
109     ${args_if}    ${kwargs_if}    CompareStream__Convert_Input    @{varargs_if}
110     ${args_else}    ${kwargs_else}    CompareStream__Convert_Input    @{varargs_else}
111     ${resp}    BuiltIn.Run_Keyword_If    &{Stream_dict}[${ODL_STREAM}] >= &{Stream_dict}[${lower_bound}]    @{args_if}    &{kwargs_if}
112     ...    ELSE    @{args_else}    &{kwargs_else}
113     [Return]    ${resp}
114
115 Run_Keyword_If_At_Most
116     [Arguments]    ${upper_bound}    ${kw_name}    @{varargs}    &{kwargs}
117     [Documentation]    Compare ${upper_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is at most ${upper_bound},
118     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
119     BuiltIn.Run_Keyword_And_Return_If    &{Stream_dict}[${ODL_STREAM}] <= &{Stream_dict}[${upper_bound}]    ${kw_name}    @{varargs}    &{kwargs}
120
121 Run_Keyword_If_At_Most_Else
122     [Arguments]    ${upper_bound}    @{varargs}
123     [Documentation]    Compare ${upper_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is at most ${upper_bound},
124     ...    run keyword defined before ELSE statement otherwise run keyword defined after ELSE statement and return its value.
125     ${position}    Collections.Get_Index_From_List    ${varargs}    \ELSE
126     BuiltIn.Run_Keyword_If    "${position}" == "-1"    BuiltIn.Fail    Missing else statement in defined expresion
127     ${varargs_if}    Collections.Get_Slice_From_List    ${varargs}    0    ${position}
128     ${varargs_else}    Collections.Get_Slice_From_List    ${varargs}    ${position+1}
129     ${args_if}    ${kwargs_if}    CompareStream__Convert_Input    @{varargs_if}
130     ${args_else}    ${kwargs_else}    CompareStream__Convert_Input    @{varargs_else}
131     ${resp}    BuiltIn.Run_Keyword_If    &{Stream_dict}[${ODL_STREAM}] >= &{Stream_dict}[${lower_bound}]    @{args_if}    &{kwargs_if}
132     ...    ELSE    @{args_else}    &{kwargs_else}
133     [Return]    ${resp}
134
135 Run_Keyword_If_More_Than
136     [Arguments]    ${lower_bound}    ${kw_name}    @{varargs}    &{kwargs}
137     [Documentation]    Compare ${lower_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is more than ${lower_bound},
138     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
139     BuiltIn.Run_Keyword_And_Return_If    &{Stream_dict}[${ODL_STREAM}] > &{Stream_dict}[${lower_bound}]    ${kw_name}    @{varargs}    &{kwargs}
140
141 Run_Keyword_If_Equals
142     [Arguments]    ${stream}    ${kw_name}    @{varargs}    &{kwargs}
143     [Documentation]    Compare ${stream} to ${ODL_STREAM} and in case ${ODL_STREAM} equals ${stream},
144     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
145     BuiltIn.Run_Keyword_And_Return_If    &{Stream_dict}[${ODL_STREAM}] == &{Stream_dict}[${stream}]    ${kw_name}    @{varargs}    &{kwargs}
146
147 Run_Keyword_If_Less_Than
148     [Arguments]    ${lower_bound}    ${kw_name}    @{varargs}    &{kwargs}
149     [Documentation]    Compare ${lower_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is less than ${lower_bound},
150     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
151     BuiltIn.Run_Keyword_And_Return_If    &{Stream_dict}[${ODL_STREAM}] < &{Stream_dict}[${lower_bound}]    ${kw_name}    @{varargs}    &{kwargs}
152
153 Run_Keyword_If_At_Least_Carbon
154     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
155     [Documentation]    Compare carbon to ${ODL_STREAM} and in case ${ODL_STREAM} is at least carbon,
156     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
157     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Least    carbon    ${kw_name}    @{varargs}    &{kwargs}
158
159 Run_Keyword_If_At_Least_Nitrogen
160     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
161     [Documentation]    Compare nitrogen to ${ODL_STREAM} and in case ${ODL_STREAM} is at least nitrogen,
162     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
163     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Least    nitrogen    ${kw_name}    @{varargs}    &{kwargs}
164
165 Run_Keyword_If_At_Least_Oxygen
166     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
167     [Documentation]    Compare oxygen to ${ODL_STREAM} and in case ${ODL_STREAM} is at least oxygen,
168     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
169     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Least    oxygen    ${kw_name}    @{varargs}    &{kwargs}
170
171 Run_Keyword_If_At_Least_Fluorine
172     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
173     [Documentation]    Compare fluorine to ${ODL_STREAM} and in case ${ODL_STREAM} is at least fluorine,
174     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
175     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Least    fluorine    ${kw_name}    @{varargs}    &{kwargs}
176
177 Run_Keyword_If_At_Most_Carbon
178     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
179     [Documentation]    Compare carbon to ${ODL_STREAM} and in case ${ODL_STREAM} is at most carbon,
180     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
181     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Most    carbon    ${kw_name}    @{varargs}    &{kwargs}
182
183 Run_Keyword_If_At_Most_Nitrogen
184     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
185     [Documentation]    Compare nitrogen to ${ODL_STREAM} and in case ${ODL_STREAM} is at most nitrogen,
186     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
187     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Most    nitrogen    ${kw_name}    @{varargs}    &{kwargs}
188
189 Run_Keyword_If_At_Most_Oxygen
190     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
191     [Documentation]    Compare oxygen to ${ODL_STREAM} and in case ${ODL_STREAM} is at most oxygen,
192     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
193     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Most    oxygen    ${kw_name}    @{varargs}    &{kwargs}
194
195 Run_Keyword_If_At_Most_Fluorine
196     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
197     [Documentation]    Compare fluorine to ${ODL_STREAM} and in case ${ODL_STREAM} is at most fluroine,
198     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
199     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_At_Most    fluorine    ${kw_name}    @{varargs}    &{kwargs}
200
201 Run_Keyword_If_More_Than_Carbon
202     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
203     [Documentation]    Compare carbon to ${ODL_STREAM} and in case ${ODL_STREAM} is more than carbon,
204     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
205     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_More_Than    carbon    ${kw_name}    @{varargs}    &{kwargs}
206
207 Run_Keyword_If_More_Than_Nitrogen
208     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
209     [Documentation]    Compare nitrogen to ${ODL_STREAM} and in case ${ODL_STREAM} is more than nitrogen,
210     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
211     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_More_Than    nitrogen    ${kw_name}    @{varargs}    &{kwargs}
212
213 Run_Keyword_If_More_Than_Oxygen
214     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
215     [Documentation]    Compare oxygen to ${ODL_STREAM} and in case ${ODL_STREAM} is more than oxygen,
216     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
217     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_More_Than    oxygen    ${kw_name}    @{varargs}    &{kwargs}
218
219 Run_Keyword_If_More_Than_Fluorine
220     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
221     [Documentation]    Compare fluorine to ${ODL_STREAM} and in case ${ODL_STREAM} is more than fluorine,
222     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
223     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_More_Than    fluorine    ${kw_name}    @{varargs}    &{kwargs}
224
225 Run_Keyword_If_Less_Than_Carbon
226     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
227     [Documentation]    Compare carbon to ${ODL_STREAM} and in case ${ODL_STREAM} is less than carbon,
228     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
229     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_Less_Than    carbon    ${kw_name}    @{varargs}    &{kwargs}
230
231 Run_Keyword_If_Less_Than_Nitrogen
232     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
233     [Documentation]    Compare nitrogen to ${ODL_STREAM} and in case ${ODL_STREAM} is less than nitrogen,
234     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
235     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_Less_Than    nitrogen    ${kw_name}    @{varargs}    &{kwargs}
236
237 Run_Keyword_If_Less_Than_Oxygen
238     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
239     [Documentation]    Compare oxygen to ${ODL_STREAM} and in case ${ODL_STREAM} is less than oxygen,
240     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
241     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_Less_Than    oxygen    ${kw_name}    @{varargs}    &{kwargs}
242
243 Run_Keyword_If_Less_Than_Fluorine
244     [Arguments]    ${kw_name}    @{varargs}    &{kwargs}
245     [Documentation]    Compare fluorine to ${ODL_STREAM} and in case ${ODL_STREAM} is less than fluorine,
246     ...    run ${kw_name} @{varargs} &{kwargs} and return its value.
247     BuiltIn.Run_Keyword_And_Return    Run_Keyword_If_Less_Than    fluorine    ${kw_name}    @{varargs}    &{kwargs}