API test cases for /core/deployments

Change-Id: Ie12cba6cf397f879e84c411a055686c024fb7b0f
diff --git a/src/test/cord-api/Framework/utils/utils.py b/src/test/cord-api/Framework/utils/utils.py
index 8b3b576..1eaa299 100644
--- a/src/test/cord-api/Framework/utils/utils.py
+++ b/src/test/cord-api/Framework/utils/utils.py
@@ -176,7 +176,7 @@
             elif type(search_dict[key]) == list:
                  if not search_dict[key]:
                     found = False
-                    break
+                    continue
                  for item in search_dict[key]:
                      if isinstance(item, dict):
                         results, found = self.search_dictionary(item, field)
@@ -196,7 +196,7 @@
     @params : getJsonDataDictList - List of dictionaries to be searched
              fieldName - Key to be searched for (ex: instance_id)
     @Returns: Returns the unique value of the Key that was provided
-    '''   
+    '''
 
     def getAllFieldValues(self, getJsonDataDictList, fieldName):
         value_list = []
@@ -212,8 +212,7 @@
         else:
            print "list of values found for ", fieldName, ";", uniq_list
         return fieldValue
-        
-        
+
 '''
 #Test
 dict_list = {
diff --git a/src/test/cord-api/Properties/RestApiProperties.py b/src/test/cord-api/Properties/RestApiProperties.py
index 25eebe0..2dfb02b 100644
--- a/src/test/cord-api/Properties/RestApiProperties.py
+++ b/src/test/cord-api/Properties/RestApiProperties.py
@@ -10,3 +10,4 @@
 CORE_USERS = '/api/core/users/'
 CORE_SERVICES = '/api/core/services/'
 CORE_INSTANCES = '/api/core/instances/'
+CORE_DEPLOYMENTS = '/api/core/deployments/'
diff --git a/src/test/cord-api/Tests/DeploymentTest.txt b/src/test/cord-api/Tests/DeploymentTest.txt
new file mode 100644
index 0000000..b0141b0
--- /dev/null
+++ b/src/test/cord-api/Tests/DeploymentTest.txt
@@ -0,0 +1,94 @@
+*** Settings ***
+Documentation     Test suite for Deployment verification
+Suite Setup       Read InputFile
+Test Template     Verify Deployment 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/Deployment.json
+${PATHFILE2}      ${CURDIR}/data/putDeployment.json
+
+*** Test Cases ***          TYPE        LISTINDEX
+Test Post Deployment-1      CREATE      0
+
+Test Get Deployment-1       RETRIEVE    0
+
+#Test Edit Deployment-1      PUT         0
+
+Test Delete Deployment-1    DELETE      0
+
+Test Post Deployment-2      CREATE      1
+
+Test Get Deployment-2       RETRIEVE    1
+
+#Test Edit Deployment-2      PUT         1
+
+Test Delete Deployment-2    DELETE      1
+
+*** Keywords ***
+Read InputFile
+    ${deploymentList}=    utils.jsonToList    ${PATHFILE}    DeploymentInfo
+    Set Suite Variable    ${dlist}    ${deploymentList}
+    ${putDeploymentList}=    utils.jsonToList    ${PATHFILE2}    DeploymentInfo
+    Set Suite Variable    ${putList}    ${putDeploymentList}
+
+Verify Deployment functionality
+    [Arguments]    ${type}    ${listIndex}
+    Run Keyword If    "${type}" == "CREATE"    Test Post Deployment API    ${listIndex}
+    Run Keyword If    "${type}" == "RETRIEVE"    Test Get Deployment API    ${listIndex}
+    Run Keyword If    "${type}" == "PUT"    Test Edit Deployment API    ${listIndex}
+    Run Keyword If    "${type}" == "DELETE"    Test Delete Deployment API    ${listIndex}
+
+Test Post Deployment API
+    [Arguments]    ${listIndex}
+    ${deploymentList} =    Get Variable Value    ${dlist}
+    ${deploymentDict}=    utils.listToDict    ${deploymentList}    ${listIndex}
+    ${api_result}=    restApi.ApiPost    CORE_DEPLOYMENTS    ${deploymentDict}
+    Should Be True    ${api_result}
+
+Test Get Deployment API
+    [Arguments]    ${listIndex}
+    ${json_result}=    restApi.ApiGet   CORE_DEPLOYMENTS
+    Log    ${json_result}
+    ${deploymentList}=    Get Variable Value    ${dlist}
+    ${deploymentDict}=    utils.listToDict    ${deploymentList}    ${listIndex}
+    ${name}=    utils.getFieldValueFromDict    ${deploymentDict}   name
+    ${getJsonDict}=    utils.getDictFromListOfDict    ${json_result}    name    ${name}
+    ${test_result}=    utils.compare_dict    ${deploymentDict}    ${getJsonDict}
+    Should Be True    ${test_result}
+
+Test Edit Deployment API
+    [Arguments]    ${listIndex}
+    ${get_result}=    restApi.ApiGet    CORE_DEPLOYMENTS
+    ${putDeploymentList}=    Get Variable Value    ${putList}
+    ${putDeploymentDict}=    utils.listToDict    ${putDeploymentList}    ${listIndex}
+    ${name}=    utils.getFieldValueFromDict    ${putDeploymentDict}    name
+    ${deploymentDict}=    utils.getDictFromListofDict    ${get_result}    name    ${name}
+    ${deploymentID}=    utils.getFieldValueFromDict    ${deploymentDict}    id
+    ${api_result}=    restApi.ApiPut    CORE_DEPLOYMENTS    ${putDeploymentDict}    ${deploymentID}
+    Should Be True    ${api_result}
+    ${getResultAfterPut}=    restApi.ApiGet    CORE_DEPLOYMENTS    ${deploymentID}
+    ${test_result}=    utils.compare_dict    ${putDeploymentDict}    ${getResultAfterPut}
+    Should Be True    ${test_result}
+
+Test Delete Deployment API
+    [Arguments]    ${listIndex}
+    ${json_result}=    restApi.ApiGet    CORE_DEPLOYMENTS
+    ${deploymentList}=    Get Variable Value    ${dlist}
+    ${deploymentDict}=    utils.listToDict    ${deploymentList}    ${listIndex}
+    ${name}=    utils.getFieldValueFromDict    ${deploymentDict}    name
+    Log    ${name}
+    ${deploymentDict}=    utils.getDictFromListofDict    ${json_result}    name  ${name}
+    Log    ${deploymentDict}
+    ${deploymentId}=    utils.getFieldValueFromDict    ${deploymentDict}    id
+    Log    ${deploymentId}
+    ${test_result}=    restApi.ApiDelete    CORE_DEPLOYMENTS    ${deploymentId}
+    Should Be True    ${test_result}
diff --git a/src/test/cord-api/Tests/data/Deployment.json b/src/test/cord-api/Tests/data/Deployment.json
new file mode 100644
index 0000000..07f0f56
--- /dev/null
+++ b/src/test/cord-api/Tests/data/Deployment.json
@@ -0,0 +1,11 @@
+{
+    "DeploymentInfo":
+    [
+        {
+            "name": "test-deployment-1"
+        },
+        {
+            "name": "test-deployment-2"
+        }
+    ]
+}
diff --git a/src/test/cord-api/Tests/data/putDeployment.json b/src/test/cord-api/Tests/data/putDeployment.json
new file mode 100644
index 0000000..07f0f56
--- /dev/null
+++ b/src/test/cord-api/Tests/data/putDeployment.json
@@ -0,0 +1,11 @@
+{
+    "DeploymentInfo":
+    [
+        {
+            "name": "test-deployment-1"
+        },
+        {
+            "name": "test-deployment-2"
+        }
+    ]
+}