You Wang | f462ee9 | 2016-12-16 13:11:43 -0800 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test suite for Deployment verification |
| 3 | Suite Setup Read InputFile |
| 4 | Test Template Verify Deployment functionality |
| 5 | Library Collections |
| 6 | Library String |
| 7 | Library OperatingSystem |
| 8 | Library XML |
| 9 | Library RequestsLibrary |
| 10 | Library ../Framework/utils/utils.py |
| 11 | Library ../Framework/restApi.py |
| 12 | |
| 13 | *** Variables *** |
| 14 | ${USER} admin |
| 15 | ${PASSWORD} admin |
| 16 | ${PATHFILE} ${CURDIR}/data/Deployment.json |
| 17 | ${PATHFILE2} ${CURDIR}/data/putDeployment.json |
| 18 | |
| 19 | *** Test Cases *** TYPE LISTINDEX |
| 20 | Test Post Deployment-1 CREATE 0 |
| 21 | |
| 22 | Test Get Deployment-1 RETRIEVE 0 |
| 23 | |
| 24 | #Test Edit Deployment-1 PUT 0 |
| 25 | |
| 26 | Test Delete Deployment-1 DELETE 0 |
| 27 | |
| 28 | Test Post Deployment-2 CREATE 1 |
| 29 | |
| 30 | Test Get Deployment-2 RETRIEVE 1 |
| 31 | |
| 32 | #Test Edit Deployment-2 PUT 1 |
| 33 | |
| 34 | Test Delete Deployment-2 DELETE 1 |
| 35 | |
| 36 | *** Keywords *** |
| 37 | Read InputFile |
| 38 | ${deploymentList}= utils.jsonToList ${PATHFILE} DeploymentInfo |
| 39 | Set Suite Variable ${dlist} ${deploymentList} |
| 40 | ${putDeploymentList}= utils.jsonToList ${PATHFILE2} DeploymentInfo |
| 41 | Set Suite Variable ${putList} ${putDeploymentList} |
| 42 | |
| 43 | Verify Deployment functionality |
| 44 | [Arguments] ${type} ${listIndex} |
| 45 | Run Keyword If "${type}" == "CREATE" Test Post Deployment API ${listIndex} |
| 46 | Run Keyword If "${type}" == "RETRIEVE" Test Get Deployment API ${listIndex} |
| 47 | Run Keyword If "${type}" == "PUT" Test Edit Deployment API ${listIndex} |
| 48 | Run Keyword If "${type}" == "DELETE" Test Delete Deployment API ${listIndex} |
| 49 | |
| 50 | Test Post Deployment API |
| 51 | [Arguments] ${listIndex} |
| 52 | ${deploymentList} = Get Variable Value ${dlist} |
| 53 | ${deploymentDict}= utils.listToDict ${deploymentList} ${listIndex} |
| 54 | ${api_result}= restApi.ApiPost CORE_DEPLOYMENTS ${deploymentDict} |
| 55 | Should Be True ${api_result} |
| 56 | |
| 57 | Test Get Deployment API |
| 58 | [Arguments] ${listIndex} |
| 59 | ${json_result}= restApi.ApiGet CORE_DEPLOYMENTS |
| 60 | Log ${json_result} |
| 61 | ${deploymentList}= Get Variable Value ${dlist} |
| 62 | ${deploymentDict}= utils.listToDict ${deploymentList} ${listIndex} |
| 63 | ${name}= utils.getFieldValueFromDict ${deploymentDict} name |
| 64 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result} name ${name} |
| 65 | ${test_result}= utils.compare_dict ${deploymentDict} ${getJsonDict} |
| 66 | Should Be True ${test_result} |
| 67 | |
| 68 | Test Edit Deployment API |
| 69 | [Arguments] ${listIndex} |
| 70 | ${get_result}= restApi.ApiGet CORE_DEPLOYMENTS |
| 71 | ${putDeploymentList}= Get Variable Value ${putList} |
| 72 | ${putDeploymentDict}= utils.listToDict ${putDeploymentList} ${listIndex} |
| 73 | ${name}= utils.getFieldValueFromDict ${putDeploymentDict} name |
| 74 | ${deploymentDict}= utils.getDictFromListofDict ${get_result} name ${name} |
| 75 | ${deploymentID}= utils.getFieldValueFromDict ${deploymentDict} id |
| 76 | ${api_result}= restApi.ApiPut CORE_DEPLOYMENTS ${putDeploymentDict} ${deploymentID} |
| 77 | Should Be True ${api_result} |
| 78 | ${getResultAfterPut}= restApi.ApiGet CORE_DEPLOYMENTS ${deploymentID} |
| 79 | ${test_result}= utils.compare_dict ${putDeploymentDict} ${getResultAfterPut} |
| 80 | Should Be True ${test_result} |
| 81 | |
| 82 | Test Delete Deployment API |
| 83 | [Arguments] ${listIndex} |
| 84 | ${json_result}= restApi.ApiGet CORE_DEPLOYMENTS |
| 85 | ${deploymentList}= Get Variable Value ${dlist} |
| 86 | ${deploymentDict}= utils.listToDict ${deploymentList} ${listIndex} |
| 87 | ${name}= utils.getFieldValueFromDict ${deploymentDict} name |
| 88 | Log ${name} |
| 89 | ${deploymentDict}= utils.getDictFromListofDict ${json_result} name ${name} |
| 90 | Log ${deploymentDict} |
| 91 | ${deploymentId}= utils.getFieldValueFromDict ${deploymentDict} id |
| 92 | Log ${deploymentId} |
| 93 | ${test_result}= restApi.ApiDelete CORE_DEPLOYMENTS ${deploymentId} |
| 94 | Should Be True ${test_result} |