blob: f0dea255235c3c19a927f7f652a89e7302c6db09 [file] [log] [blame]
fujinhuaa12f3bb2017-09-14 16:28:50 +08001#Robot functions that will be shared also with other tests
Mariusz Wagner831baff2018-09-14 14:24:02 +02002*** Settings ***
3Library OperatingSystem
Mariusz Wagner39581392018-09-24 11:52:15 +02004Library HttpLibrary.HTTP
fujinhuaa12f3bb2017-09-14 16:28:50 +08005
6*** Keywords ***
7json_from_file
8#Robot function to extract the json object from a file
9 [Arguments] ${file_path}
Mariusz Wagner831baff2018-09-14 14:24:02 +020010 ${json_file}= Get File ${file_path}
fujinhuaa12f3bb2017-09-14 16:28:50 +080011 ${json_object}= Evaluate json.loads('''${json_file}''') json
Mariusz Wagner831baff2018-09-14 14:24:02 +020012 [Return] ${json_object}
fujinhuaa12f3bb2017-09-14 16:28:50 +080013
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}
Mariusz Wagner831baff2018-09-14 14:24:02 +020018 [Return] ${json_string}
fujinhuaa12f3bb2017-09-14 16:28:50 +080019
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]}
Mariusz Wagner831baff2018-09-14 14:24:02 +020025 [Return] ${generated_ip}
26
27Get Data From File
28 [Arguments] ${file}
29 ${data}= Get File ${file}
30 [Return] ${data}