Support both empty data formats 15/106615/1 pre-potassium
authorSangwook Ha <sangwook.ha@verizon.com>
Thu, 22 Jun 2023 08:44:26 +0000 (01:44 -0700)
committerSangwook Ha <sangwook.ha@verizon.com>
Thu, 22 Jun 2023 08:45:24 +0000 (01:45 -0700)
Depending on the active XML library the output of empty NETCONF data
can be either

<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>

or

<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"></data>

Support both options to make the test results more stable.

Change-Id: I65fe5c428a4d8da14ddc6bce2f411e02692c2659
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
csit/suites/netconf/CRUD-ACTION/CRUD-ACTION.robot
csit/suites/netconf/CRUD/CRUD-RPC.robot
csit/suites/netconf/CRUD/CRUD.robot

index 3a76977c490ff596261c905d74038ae0ff924986..b878485d4006e57ae8e13b3a3650556ed492f8b7 100644 (file)
@@ -67,7 +67,8 @@ Wait_For_Device_To_Become_Connected
 
 Check_Device_Data_Is_Empty
     [Documentation]    Get the device data and make sure it is empty.
-    Check_Config_Data    <data xmlns\="${ODL_NETCONF_NAMESPACE}"/>
+    ${escaped} =    BuiltIn.Regexp_Escape    ${ODL_NETCONF_NAMESPACE}
+    Check_Config_Data    <data xmlns\="${escaped}"(\/>|><\/data>)    ${True}
 
 Invoke_Yang1.1_Action_Via_Xml_Post
     [Documentation]    Send a sample test data label into the device and check that the request went OK.
@@ -148,9 +149,12 @@ Get_Config_Data
     RETURN    ${data}
 
 Check_Config_Data
-    [Arguments]    ${expected}    ${contains}=False
+    [Arguments]    ${expected}    ${regex}=False    ${contains}=False
     ${data} =    Get_Config_Data
-    IF    not ${contains}
+    IF    ${regex}
+        BuiltIn.Should Match Regexp    ${data}    ${expected}
+    ELSE IF    ${contains}
+        BuiltIn.Should_Contain    ${data}    ${expected}
+    ELSE
         BuiltIn.Should_Be_Equal_As_Strings    ${data}    ${expected}
     END
-    IF    ${contains}    BuiltIn.Should_Contain    ${data}    ${expected}
index b6a80668d3ee50c36b25f3e8715476b2797d11b7..9a90e4502ddf2f906eeff67f9ca5bdc43c307aaa 100644 (file)
@@ -80,7 +80,8 @@ Wait_For_Device_To_Become_Connected
 
 Check_Device_Data_Is_Empty
     [Documentation]    Get the device data and make sure it is empty.
-    Check_Config_Data    <data xmlns\="${ODL_NETCONF_NAMESPACE}"/>
+    ${escaped}=    BuiltIn.Regexp_Escape    ${ODL_NETCONF_NAMESPACE}
+    Check_Config_Data    <data xmlns\="${escaped}"(\/>|><\/data>)    ${True}
 
 Create_Device_Data_Label_Via_Xml
     [Documentation]    Send a sample test data label into the device and check that the request went OK.
@@ -229,7 +230,8 @@ Delete_Device_Data
 
 Check_Device_Data_Is_Deleted
     [Documentation]    Get the device data and make sure it is empty again.
-    Check_Config_Data    <data xmlns\="${ODL_NETCONF_NAMESPACE}"/>
+    ${escaped}=    BuiltIn.Regexp_Escape    ${ODL_NETCONF_NAMESPACE}
+    Check_Config_Data    <data xmlns\="${escaped}"(\/>|><\/data>)    ${True}
 
 Deconfigure_Device_From_Netconf
     [Documentation]    Make request to deconfigure the testtool device on Netconf connector.
@@ -279,9 +281,12 @@ Get_Config_Data
     RETURN    ${data}
 
 Check_Config_Data
-    [Arguments]    ${expected}    ${contains}=False
+    [Arguments]    ${expected}    ${regex}=False    ${contains}=False
     ${data}=    Get_Config_Data
-    IF    not ${contains}
+    IF    ${regex}
+        BuiltIn.Should Match Regexp    ${data}    ${expected}
+    ELSE IF    ${contains}
+        BuiltIn.Should_Contain    ${data}    ${expected}
+    ELSE
         BuiltIn.Should_Be_Equal_As_Strings    ${data}    ${expected}
     END
-    IF    ${contains}    BuiltIn.Should_Contain    ${data}    ${expected}
index d01bc69aaba359338f7d95fd5c94b6de7a85955d..f634d2236a3d750683ea21ea4341ab8f27a994ae 100644 (file)
@@ -71,7 +71,8 @@ Wait_For_Device_To_Become_Connected
 
 Check_Device_Data_Is_Empty
     [Documentation]    Get the device data and make sure it is empty.
-    Check_Config_Data    <data xmlns\="${ODL_NETCONF_NAMESPACE}"/>
+    ${escaped}=    BuiltIn.Regexp_Escape    ${ODL_NETCONF_NAMESPACE}
+    Check_Config_Data    <data xmlns\="${escaped}"(\/>|><\/data>)    ${True}
 
 Create_Device_Data_Label_Via_Xml
     [Documentation]    Send a sample test data label into the device and check that the request went OK.
@@ -212,7 +213,8 @@ Delete_Device_Data
 
 Check_Device_Data_Is_Deleted
     [Documentation]    Get the device data and make sure it is empty again.
-    Check_Config_Data    <data xmlns\="${ODL_NETCONF_NAMESPACE}"/>
+    ${escaped}=    BuiltIn.Regexp_Escape    ${ODL_NETCONF_NAMESPACE}
+    Check_Config_Data    <data xmlns\="${escaped}"(\/>|><\/data>)    ${True}
 
 Deconfigure_Device_From_Netconf
     [Documentation]    Make request to deconfigure the testtool device on Netconf connector.
@@ -259,12 +261,15 @@ Get_Config_Data
     RETURN    ${data}
 
 Check_Config_Data
-    [Arguments]    ${expected}    ${contains}=False
+    [Arguments]    ${expected}    ${regex}=False    ${contains}=False
     ${data}=    Get_Config_Data
-    IF    not ${contains}
+    IF    ${regex}
+        BuiltIn.Should Match Regexp    ${data}    ${expected}
+    ELSE IF    ${contains}
+        BuiltIn.Should_Contain    ${data}    ${expected}
+    ELSE
         BuiltIn.Should_Be_Equal_As_Strings    ${data}    ${expected}
     END
-    IF    ${contains}    BuiltIn.Should_Contain    ${data}    ${expected}
 
 Count_Netconf_Connectors
     ${count}=    NetconfKeywords.Count_Netconf_Connectors_For_Device    ${device_name}