Fix typo in throughpcep suite.
[integration/test.git] / csit / libraries / NetconfViaRestconf.robot
index be5c48ea4c51823b6b89221a1cd908120dee0022..947dd3e2c7d22b027b484aa543a933b921ccbe89 100644 (file)
@@ -76,6 +76,14 @@ Resolve_Xml_Data_From_Template_Folder
     ${xml_data}=    Strip_Endline_And_Apply_Substitutions_From_Mapping    ${data_template}    ${mapping_as_string}
     [Return]    ${xml_data}
 
+Resolve_Json_Data_From_Template_Folder
+    [Arguments]    ${folder}    ${mapping_as_string}
+    [Documentation]    Read data template from folder, strip endline, make changes according to mapping, return the result.
+    ${data_template}=    OperatingSystem.Get_File    ${folder}${/}data.json
+    BuiltIn.Log    ${data_template}
+    ${json_data}=    Strip_Endline_And_Apply_Substitutions_From_Mapping    ${data_template}    ${mapping_as_string}
+    [Return]    ${json_data}
+
 Strip_Endline_And_Apply_Substitutions_From_Mapping
     [Arguments]    ${template_as_string}    ${mapping_as_string}
     [Documentation]    Strip endline, apply substitutions, Log and return the result.
@@ -94,7 +102,7 @@ Post_Xml_Via_Restconf
     # As seen in previous two Keywords, Post does not need long specific URI.
     # But during Lithium development, Post ceased to do merge, so those Keywords do not work anymore.
     # This Keyword can still be used with specific URI to create a new container and fail if a container was already present.
-    ${response}=    RequestsLibrary.Post    ${NetconfViaRestconf__active_config_session}    ${uri_part}    data=${xml_data}
+    ${response}=    RequestsLibrary.Post Request    ${NetconfViaRestconf__active_config_session}    ${uri_part}    data=${xml_data}
     BuiltIn.Log    ${response.text}
     BuiltIn.Should_Be_Empty    ${response.text}
     BuiltIn.Should_Be_Equal_As_Strings    ${response.status_code}    204
@@ -106,12 +114,32 @@ Post_Xml_Template_Folder_Via_Restconf
     ${xml_data}=    Resolve_Xml_Data_From_Template_Folder    ${folder}    ${mapping_as_string}
     Post_Xml_Via_Restconf    ${uri_part}    ${xml_data}
 
+Post_Json_Via_Restconf
+    [Arguments]    ${uri_part}    ${json_data}
+    [Documentation]    Post JSON data to given controller-config URI, check reponse text is empty and status_code is 204.
+    BuiltIn.Log    ${uri_part}
+    BuiltIn.Log    ${json_data}
+    # As seen in previous two Keywords, Post does not need long specific URI.
+    # But during Lithium development, Post ceased to do merge, so those Keywords do not work anymore.
+    # This Keyword can still be used with specific URI to create a new container and fail if a container was already present.
+    ${response}=    RequestsLibrary.Post    ${NetconfViaRestconf__active_config_session}    ${uri_part}    data=${json_data}    headers=${HEADERS_YANG_JSON}
+    BuiltIn.Log    ${response.text}
+    BuiltIn.Should_Be_Empty    ${response.text}
+    BuiltIn.Should_Be_Equal_As_Strings    ${response.status_code}    204
+
+Post_Json_Template_Folder_Via_Restconf
+    [Arguments]    ${folder}    ${mapping_as_string}={}
+    [Documentation]    Resolve URI and data from folder, POST to restconf.
+    ${uri_part}=    Resolve_URI_From_Template_Folder    ${folder}    ${mapping_as_string}
+    ${json_data}=    Resolve_Json_Data_From_Template_Folder    ${folder}    ${mapping_as_string}
+    Post_Json_Via_Restconf    ${uri_part}    ${json_data}
+
 Put_Xml_Via_Restconf
     [Arguments]    ${uri_part}    ${xml_data}
     [Documentation]    Put XML data to given controller-config URI, check reponse text is empty and status_code is one of allowed ones.
     BuiltIn.Log    ${uri_part}
     BuiltIn.Log    ${xml_data}
-    ${response}=    RequestsLibrary.Put    ${NetconfViaRestconf__active_config_session}    ${uri_part}    data=${xml_data}
+    ${response}=    RequestsLibrary.Put Request    ${NetconfViaRestconf__active_config_session}    ${uri_part}    data=${xml_data}
     BuiltIn.Log    ${response.text}
     BuiltIn.Log    ${response.status_code}
     BuiltIn.Should_Be_Empty    ${response.text}
@@ -124,11 +152,29 @@ Put_Xml_Template_Folder_Via_Restconf
     ${xml_data}=    Resolve_Xml_Data_From_Template_Folder    ${folder}    ${mapping_as_string}
     Put_Xml_Via_Restconf    ${uri_part}    ${xml_data}
 
+Put_Json_Via_Restconf
+    [Arguments]    ${uri_part}    ${json_data}
+    [Documentation]    Put JSON data to given controller-config URI, check reponse text is empty and status_code is one of allowed ones.
+    BuiltIn.Log    ${uri_part}
+    BuiltIn.Log    ${json_data}
+    ${response}=    RequestsLibrary.Put Request    ${NetconfViaRestconf__active_config_session}    ${uri_part}    data=${json_data}    headers=${HEADERS_YANG_JSON}
+    BuiltIn.Log    ${response.text}
+    BuiltIn.Log    ${response.status_code}
+    BuiltIn.Should_Be_Empty    ${response.text}
+    BuiltIn.Should_Contain    ${allowed_status_codes}    ${response.status_code}
+
+Put_Json_Template_Folder_Via_Restconf
+    [Arguments]    ${folder}    ${mapping_as_string}={}
+    [Documentation]    Resolve URI and data from folder, PUT to controller config.
+    ${uri_part}=    Resolve_URI_From_Template_Folder    ${folder}    ${mapping_as_string}
+    ${json_data}=    Resolve_Json_Data_From_Template_Folder    ${folder}    ${mapping_as_string}
+    Put_Json_Via_Restconf    ${uri_part}    ${json_data}
+
 Delete_Via_Restconf
     [Arguments]    ${uri_part}
     [Documentation]    Delete resource at controller-config URI, check reponse text is empty and status_code is 204.
     BuiltIn.Log    ${uri_part}
-    ${response}=    RequestsLibrary.Delete    ${NetconfViaRestconf__active_config_session}    ${uri_part}
+    ${response}=    RequestsLibrary.Delete Request    ${NetconfViaRestconf__active_config_session}    ${uri_part}
     BuiltIn.Log    ${response.text}
     BuiltIn.Should_Be_Empty    ${response.text}
     BuiltIn.Should_Contain    ${allowed_status_codes}    ${response.status_code}