[SO] SO release image for CSIT testing
[integration/csit.git] / tests / common.robot
1 #Robot functions that will be shared also with other tests
2 *** Settings ***
3 Library     OperatingSystem
4
5 *** Keywords ***
6 json_from_file
7 #Robot function to extract the json object from a file
8     [Arguments]    ${file_path}
9     ${json_file}=    Get File    ${file_path}
10     ${json_object}=    Evaluate    json.loads('''${json_file}''')    json
11     [Return]    ${json_object}
12
13 string_from_json
14 #Robot function to transform the json object to a string
15     [Arguments]    ${json_value}
16     ${json_string}=   Stringify Json     ${json_value}
17     [Return]    ${json_string}
18
19 random_ip
20 #Robot function to generate a random IP
21     [Arguments]
22     ${numbers}=    Evaluate    random.sample([x for x in range(1, 256)], 4)    random
23     ${generated_ip}=    Catenate    ${numbers[0]}.${numbers[1]}.${numbers[2]}.${numbers[3]}
24     [Return]    ${generated_ip}
25
26 Get Data From File
27     [Arguments]    ${file}
28     ${data}=    Get File    ${file}
29     [Return]    ${data}