You Wang | 123d694 | 2017-03-01 12:33:02 -0800 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test suite for Node API verification |
| 3 | Suite Setup Read InputFile |
| 4 | Test Template Verify Node API 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 | | Variables | ../Properties/RestApiProperties.py |
| 13 | |
| 14 | *** Variables *** |
| 15 | ${USER} admin |
| 16 | ${PASSWORD} admin |
| 17 | ${PATHFILE} ${CURDIR}/data/Node.json |
| 18 | | ${IP} | ${SERVER_IP} |
| 19 | | ${PORT} | ${SERVER_PORT} |
| 20 | |
| 21 | *** Test Cases *** TYPE LISTINDEX |
| 22 | Test Post Node-1 CREATE 0 |
| 23 | |
| 24 | Test Get Node-1 RETRIEVE 0 |
| 25 | |
| 26 | Test Delete Node-1 DELETE 0 |
| 27 | |
| 28 | Test Post Node-2 CREATE 1 |
| 29 | |
| 30 | Test Get Node-2 RETRIEVE 1 |
| 31 | |
| 32 | Test Delete Node-2 DELETE 1 |
| 33 | |
| 34 | *** Keywords *** |
| 35 | Read InputFile |
| 36 | ${nodeList}= utils.jsonToList ${PATHFILE} NodeInfo |
| 37 | Set Suite Variable ${nlist} ${nodeList} |
| 38 | ${siteDeployment}= Catenate SEPARATOR= http:// ${IP} : ${PORT} /api/core/sitedeployments/1/ |
| 39 | Set Suite Variable ${siteDeployment} ${siteDeployment} |
| 40 | |
| 41 | Verify Node API functionality |
| 42 | [Arguments] ${type} ${listIndex} |
| 43 | Run Keyword If "${type}" == "CREATE" Test Post Node API ${listIndex} |
| 44 | Run Keyword If "${type}" == "RETRIEVE" Test Get Node API ${listIndex} |
| 45 | Run Keyword If "${type}" == "DELETE" Test Delete Node API ${listIndex} |
| 46 | |
| 47 | Test Post Node API |
| 48 | [Arguments] ${listIndex} |
| 49 | ${nodeList}= Get Variable Value ${nlist} |
| 50 | ${nodeDict}= utils.listToDict ${nodeList} ${listIndex} |
| 51 | ${siteDeployment}= Get Variable Value ${siteDeployment} |
| 52 | ${nodeDict}= utils.setFieldValueInDict ${nodeDict} site_deployment ${siteDeployment} |
| 53 | ${api_result}= restApi.ApiPost CORE_NODES ${nodeDict} |
| 54 | Should Be True ${api_result} |
| 55 | |
| 56 | Test Get Node API |
| 57 | [Arguments] ${listIndex} |
| 58 | ${json_result}= restApi.ApiGet CORE_NODES |
| 59 | Log ${json_result} |
| 60 | ${nodeList}= Get Variable Value ${nlist} |
| 61 | ${nodeDict}= utils.listToDict ${nodeList} ${listIndex} |
| 62 | ${siteDeployment}= Get Variable Value ${siteDeployment} |
| 63 | ${nodeDict}= utils.setFieldValueInDict ${nodeDict} site_deployment ${siteDeployment} |
| 64 | ${name}= utils.getFieldValueFromDict ${nodeDict} name |
| 65 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result} name ${name} |
| 66 | ${test_result}= utils.compare_dict ${nodeDict} ${getJsonDict} |
| 67 | Should Be True ${test_result} |
| 68 | |
| 69 | Test Delete Node API |
| 70 | [Arguments] ${listIndex} |
| 71 | ${json_result}= restApi.ApiGet CORE_NODES |
| 72 | ${nodeList}= Get Variable Value ${nlist} |
| 73 | ${nodeDict}= utils.listToDict ${nodeList} ${listIndex} |
| 74 | ${name}= utils.getFieldValueFromDict ${nodeDict} name |
| 75 | Log ${name} |
| 76 | ${nodeDict}= utils.getDictFromListofDict ${json_result} name ${name} |
| 77 | Log ${nodeDict} |
| 78 | ${nodeId}= utils.getFieldValueFromDict ${nodeDict} id |
| 79 | Log ${nodeId} |
| 80 | ${test_result}= restApi.ApiDelete CORE_NODES ${nodeId} |
| 81 | Should Be True ${test_result} |