blob: 944be6b9f183c0307f3d5211b32d32acb82d2d8d [file] [log] [blame]
fujinhuaa12f3bb2017-09-14 16:28:50 +08001#Robot functions that will be shared also with other tests
2
3*** Keywords ***
4json_from_file
5#Robot function to extract the json object from a file
6 [Arguments] ${file_path}
7 ${json_file}= Get file ${file_path}
8 ${json_object}= Evaluate json.loads('''${json_file}''') json
9 [return] ${json_object}
10
11string_from_json
12#Robot function to transform the json object to a string
13 [Arguments] ${json_value}
14 ${json_string}= Stringify Json ${json_value}
15 [return] ${json_string}
16
17random_ip
18#Robot function to generate a random IP
19 [Arguments]
20 ${numbers}= Evaluate random.sample([x for x in range(1, 256)], 4) random
21 ${generated_ip}= Catenate ${numbers[0]}.${numbers[1]}.${numbers[2]}.${numbers[3]}
22 [return] ${generated_ip}