blob: f0dea255235c3c19a927f7f652a89e7302c6db09 [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001#Robot functions that will be shared also with other tests
2*** Settings ***
3Library OperatingSystem
4Library HttpLibrary.HTTP
5
6*** Keywords ***
7json_from_file
8#Robot function to extract the json object from a file
9 [Arguments] ${file_path}
10 ${json_file}= Get File ${file_path}
11 ${json_object}= Evaluate json.loads('''${json_file}''') json
12 [Return] ${json_object}
13
14string_from_json
15#Robot function to transform the json object to a string
16 [Arguments] ${json_value}
17 ${json_string}= Stringify Json ${json_value}
18 [Return] ${json_string}
19
20random_ip
21#Robot function to generate a random IP
22 [Arguments]
23 ${numbers}= Evaluate random.sample([x for x in range(1, 256)], 4) random
24 ${generated_ip}= Catenate ${numbers[0]}.${numbers[1]}.${numbers[2]}.${numbers[3]}
25 [Return] ${generated_ip}
26
27Get Data From File
28 [Arguments] ${file}
29 ${data}= Get File ${file}
30 [Return] ${data}