API test cases for /core/nodes

Change-Id: Icee210b7aae43fa88f16a39c0f3c6d28630d763b
diff --git a/src/test/cord-api/Properties/RestApiProperties.py b/src/test/cord-api/Properties/RestApiProperties.py
index 29a7563..1dbe83b 100644
--- a/src/test/cord-api/Properties/RestApiProperties.py
+++ b/src/test/cord-api/Properties/RestApiProperties.py
@@ -14,3 +14,5 @@
 CORE_SANITY_INSTANCES = '/api/core/instances/?no_hyperlinks=1'
 CORE_SANITY_SLICES = '/api/core/slices/?no_hyperlinks=1'
 CORE_SLICES = '/api/core/slices/'
+CORE_SANITY_NODES = '/api/core/nodes/?no_hyperlinks=1'
+CORE_NODES = '/api/core/nodes/'
diff --git a/src/test/cord-api/Tests/SanityNode.txt b/src/test/cord-api/Tests/SanityNode.txt
new file mode 100644
index 0000000..7f57f9a
--- /dev/null
+++ b/src/test/cord-api/Tests/SanityNode.txt
@@ -0,0 +1,72 @@
+*** Settings ***
+Documentation     Test suite for Node verification
+Suite Setup       Read InputFile
+Test Template     Verify Node functionality
+Library           Collections
+Library           String
+Library           OperatingSystem
+Library           XML
+Library           RequestsLibrary
+Library           ../Framework/utils/utils.py
+Library           ../Framework/restApi.py
+
+*** Variables ***
+${USER}           admin
+${PASSWORD}       admin
+${PATHFILE}       ${CURDIR}/data/sanityNode.json
+
+*** Test Cases ***      TYPE        LISTINDEX
+Test Post Node-1        CREATE      0
+
+#Test Get Node-1         RETRIEVE    0
+
+Test Delete Node-1      DELETE      0
+
+Test Post Node-2        CREATE      1
+
+#Test Get Node-2         RETRIEVE    1
+
+Test Delete Node-2      DELETE      1
+
+*** Keywords ***
+Read InputFile
+    ${nodeList}=    utils.jsonToList    ${PATHFILE}    NodeInfo
+    Set Suite Variable    ${nlist}    ${nodeList}
+
+Verify Node functionality
+    [Arguments]    ${type}    ${listIndex}
+    Run Keyword If    "${type}" == "CREATE"    Test Post Node API    ${listIndex}
+    Run Keyword If    "${type}" == "RETRIEVE"    Test Get Node API    ${listIndex}
+    Run Keyword If    "${type}" == "DELETE"    Test Delete Node API    ${listIndex}
+
+Test Post Node API
+    [Arguments]    ${listIndex}
+    ${nodeList}=    Get Variable Value    ${nlist}
+    ${nodeDict}=    utils.listToDict    ${nodeList}    ${listIndex}
+    ${api_result}=    restApi.ApiPost    CORE_SANITY_NODES    ${nodeDict}
+    Should Be True    ${api_result}
+
+Test Get Node API
+    [Arguments]    ${listIndex}
+    ${json_result}=    restApi.ApiGet   CORE_NODES
+    Log    ${json_result}
+    ${nodeList}=    Get Variable Value    ${nlist}
+    ${nodeDict}=    utils.listToDict    ${nodeList}    ${listIndex}
+    ${name}=    utils.getFieldValueFromDict    ${nodeDict}   name
+    ${getJsonDict}=    utils.getDictFromListOfDict    ${json_result}    name    ${name}
+    ${test_result}=    utils.compare_dict    ${nodeDict}    ${getJsonDict}
+    Should Be True    ${test_result}
+
+Test Delete Node API
+    [Arguments]    ${listIndex}
+    ${json_result}=    restApi.ApiGet    CORE_NODES
+    ${nodeList}=    Get Variable Value    ${nlist}
+    ${nodeDict}=    utils.listToDict    ${nodeList}    ${listIndex}
+    ${name}=    utils.getFieldValueFromDict    ${nodeDict}    name
+    Log    ${name}
+    ${nodeDict}=    utils.getDictFromListofDict    ${json_result}    name  ${name}
+    Log    ${nodeDict}
+    ${nodeId}=    utils.getFieldValueFromDict    ${nodeDict}    id
+    Log    ${nodeId}
+    ${test_result}=    restApi.ApiDelete    CORE_NODES    ${nodeId}
+    Should Be True    ${test_result}
diff --git a/src/test/cord-api/Tests/data/sanityNode.json b/src/test/cord-api/Tests/data/sanityNode.json
new file mode 100644
index 0000000..d726f77
--- /dev/null
+++ b/src/test/cord-api/Tests/data/sanityNode.json
@@ -0,0 +1,13 @@
+{
+    "NodeInfo":
+    [
+        {
+            "name": "test-node-1",
+            "site_deployment": "1"
+        },
+        {
+            "name": "test-node-2",
+            "site_deployment": "1"
+        }
+    ]
+}