X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Flibraries%2FTemplatedRequests.robot;h=6bc0e241fd45808cc0c165fbbb937c9354ffadfe;hb=be469c08b67312a58822a01893874da38cc4ca0d;hp=6d4d746bfbfa8efa07a3ab3e0691d373ee079491;hpb=a9e61a7db5a91c3f2598f642670abafbf8a9b57d;p=integration%2Ftest.git diff --git a/csit/libraries/TemplatedRequests.robot b/csit/libraries/TemplatedRequests.robot index 6d4d746bfb..6bc0e241fd 100644 --- a/csit/libraries/TemplatedRequests.robot +++ b/csit/libraries/TemplatedRequests.robot @@ -110,9 +110,10 @@ Documentation Resource for supporting http Requests based on data stored in ... perhaps explicit ${ACCEPT_JSON} will be better, even if it sends few bytes more? Library Collections Library OperatingSystem +Library String Library RequestsLibrary Library ${CURDIR}/norm_json.py -Variables ${CURDIR}/../variables/Variables.py +Resource ${CURDIR}/../variables/Variables.robot *** Variables *** # TODO: Make the following list more narrow when streams without Bug 2594 fix (up to beryllium) are no longer used. @@ -128,7 +129,7 @@ Variables ${CURDIR}/../variables/Variables.py *** Keywords *** Create_Default_Session - [Arguments] ${url}=http://${ODL_SYSTEM_IP}:${RESTCONFPORT} ${auth}=${AUTH} ${timeout}=1 ${max_retries}=0 + [Arguments] ${url}=http://${ODL_SYSTEM_IP}:${RESTCONFPORT} ${auth}=${AUTH} ${timeout}=${DEFAULT_TIMEOUT_HTTP} ${max_retries}=0 [Documentation] Create "default" session to ${url} with authentication and connection parameters. ... This Keyword is in this Resource only so that user do not need to call RequestsLibrary directly. RequestsLibrary.Create_Session alias=default url=${url} auth=${auth} timeout=${timeout} max_retries=${max_retries} @@ -292,13 +293,24 @@ Resolve_Jmes_Path ${expression} = BuiltIn.Set Variable If ${read_jmes_file} == ${true} ${jmes_expression} ${EMPTY} [Return] ${expression} +Resolve_Volatiles_Path + [Arguments] ${folder} + [Documentation] Reads Volatiles List from file ${folder}${/}volatiles.list if the file exists and + ... returns the Volatiles List. Empty string is returned otherwise. + ${read_volatiles_file} = BuiltIn.Run Keyword And Return Status OperatingSystem.File Should Exist ${folder}${/}volatiles.list + Return From Keyword If ${read_volatiles_file} == ${false} ${EMPTY} + ${volatiles}= OperatingSystem.Get_File ${folder}${/}volatiles.list + ${volatiles_list}= String.Split_String ${volatiles} ${\n} + [Return] ${volatiles_list} + Get_Templated [Arguments] ${folder} ${accept} ${mapping}={} ${session}=default ${normalize_json}=False ${http_timeout}=${EMPTY} [Documentation] Resolve URI from folder, call Get_From_Uri, return response text. ${uri} = Resolve_Text_From_Template_Folder folder=${folder} base_name=location extension=uri mapping=${mapping} ${jmes_expression} = Resolve_Jmes_Path ${folder} + ${volatiles_list}= Resolve_Volatiles_Path ${folder} ${response_text} = Get_From_Uri uri=${uri} accept=${accept} session=${session} normalize_json=${normalize_json} jmes_path=${jmes_expression} - ... http_timeout=${http_timeout} + ... http_timeout=${http_timeout} keys_with_volatiles=${volatiles_list} [Return] ${response_text} Put_Templated @@ -340,6 +352,7 @@ Verify_Response_Templated Get_From_Uri [Arguments] ${uri} ${accept}=${ACCEPT_EMPTY} ${session}=default ${normalize_json}=False ${jmes_path}=${EMPTY} ${http_timeout}=${EMPTY} + ... ${keys_with_volatiles}=${EMPTY} [Documentation] GET data from given URI, check status code and return response text. ... \${accept} is a Python object with headers to use. ... If \${normalize_json}, normalize as JSON text before returning. @@ -349,7 +362,7 @@ Get_From_Uri ... ELSE RequestsLibrary.Get_Request alias=${session} uri=${uri} headers=${accept} timeout=${http_timeout} Check_Status_Code ${response} BuiltIn.Run_Keyword_Unless ${normalize_json} BuiltIn.Return_From_Keyword ${response.text} - ${text_normalized} = norm_json.normalize_json_text ${response.text} jmes_path=${jmes_path} + ${text_normalized} = norm_json.normalize_json_text ${response.text} jmes_path=${jmes_path} keys_with_volatiles=${keys_with_volatiles} [Return] ${text_normalized} Put_To_Uri