delete device testcase + test improvements

Change-Id: Ia2b6d5c2912e5c513e2ac08efa1a691a89d4c5c0
diff --git a/libraries/utils.robot b/libraries/utils.robot
index ad14d72..4541bbd 100644
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -39,7 +39,7 @@
     [Arguments]    ${serial_number}    ${admin_state}    ${oper_status}    ${connect_status}
     [Documentation]    Parses the output of "voltctl device list" and inspects device ${serial_number}
     ...    Arguments are matched for device states of: "admin_state", "oper_status", and "connect_status"
-    ${output}=    Run    ${VOLTCTL_CONFIG} voltctl device list -o json
+    ${output}=    Run    ${VOLTCTL_CONFIG}; voltctl device list -o json
     ${jsondata}=    To Json    ${output}
     Log    ${jsondata}
     ${length}=    Get Length    ${jsondata}
@@ -54,6 +54,34 @@
     Should Be Equal    ${opstatus}    ${oper_status}    Device ${serial_number} oper_status != ACTIVE    values=False
     Should Be Equal    ${cstatus}    ${connect_status}    Device ${serial_number} connect_status != REACHABLE    values=False
 
+Get Device ID From SN
+    [Arguments]    ${serial_number}
+    [Documentation]    Gets the device id by matching for ${serial_number}
+    ${output}=    Run    ${VOLTCTL_CONFIG}; voltctl device list -o json
+    ${jsondata}=    To Json    ${output}
+    Log    ${jsondata}
+    ${length}=    Get Length    ${jsondata}
+    : FOR    ${INDEX}    IN RANGE    0    ${length}
+    \    ${value}=    Get From List    ${jsondata}    ${INDEX}
+    \    ${id}=    Get From Dictionary    ${value}    id
+    \    ${sn}=    Get From Dictionary    ${value}    serialnumber
+    \    Run Keyword If    '${sn}' == '${serial_number}'    Exit For Loop
+    [Return]    ${id}
+
+Validate Device Removed
+    [Arguments]    ${id}
+    [Documentation]    Verifys that device, ${serial_number}, has been removed
+    ${output}=    Run    ${VOLTCTL_CONFIG}; voltctl device list -o json
+    ${jsondata}=    To Json    ${output}
+    Log    ${jsondata}
+    ${length}=    Get Length    ${jsondata}
+    @{ids}=    Create List
+    : FOR    ${INDEX}    IN RANGE    0    ${length}
+    \    ${value}=    Get From List    ${jsondata}    ${INDEX}
+    \    ${device_id}=    Get From Dictionary    ${value}    id
+    \    Append To List    ${ids}    ${device_id}
+    List Should Not Contain Value    ${ids}    ${id}
+
 Check CLI Tools Configured
     [Documentation]    Tests that use 'voltctl' and 'kubectl' should execute this keyword in suite setup
     # check voltctl and kubectl configured