Suchitra Vemuri | f7410a9 | 2017-05-16 17:04:05 -0700 | [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 *** |
Suchitra Vemuri | f7410a9 | 2017-05-16 17:04:05 -0700 | [diff] [blame] | 15 | ${PATHFILE} ${CURDIR}/data/Ch_Node.json |
| 16 | ${IP} ${SERVER_IP} |
| 17 | ${PORT} ${SERVER_PORT} |
| 18 | |
| 19 | *** Test Cases *** TYPE LISTINDEX |
| 20 | Test Post Node-1 CREATE 0 |
| 21 | |
| 22 | Test Get Node-1 RETRIEVE 0 |
| 23 | |
| 24 | Test Delete Node-1 DELETE 0 |
| 25 | |
| 26 | Test Post Node-2 CREATE 1 |
| 27 | |
| 28 | Test Get Node-2 RETRIEVE 1 |
| 29 | |
| 30 | Test Delete Node-2 DELETE 1 |
| 31 | |
| 32 | *** Keywords *** |
| 33 | Read InputFile |
| 34 | ${nodeList}= utils.jsonToList ${PATHFILE} NodeInfo |
| 35 | Set Suite Variable ${nlist} ${nodeList} |
| 36 | ${siteDeployment}= Catenate SEPARATOR= http:// ${IP} : ${PORT} |
| 37 | ... /api/core/sitedeployments/1/ |
| 38 | Set Suite Variable ${siteDeployment} ${siteDeployment} |
| 39 | |
| 40 | Verify Node API functionality |
| 41 | [Arguments] ${type} ${listIndex} |
| 42 | Run Keyword If "${type}" == "CREATE" Test Post Node API ${listIndex} |
| 43 | Run Keyword If "${type}" == "RETRIEVE" Test Get Node API ${listIndex} |
| 44 | Run Keyword If "${type}" == "DELETE" Test Delete Node API ${listIndex} |
| 45 | |
| 46 | Test Post Node API |
| 47 | [Arguments] ${listIndex} |
| 48 | ${nodeList}= Get Variable Value ${nlist} |
| 49 | ${nodeDict}= utils.listToDict ${nodeList} ${listIndex} |
| 50 | ${api_result}= restApi.ApiPost CH_CORE_NODES ${nodeDict} |
| 51 | Should Be True ${api_result} |
| 52 | |
| 53 | Test Get Node API |
| 54 | [Arguments] ${listIndex} |
| 55 | ${json_result}= restApi.ApiGet CH_CORE_NODES |
| 56 | ${json_result_list}= Get From Dictionary ${json_result} items |
| 57 | Log ${json_result_list} |
| 58 | ${nodeList}= Get Variable Value ${nlist} |
| 59 | ${nodeDict}= utils.listToDict ${nodeList} ${listIndex} |
| 60 | ${name}= utils.getFieldValueFromDict ${nodeDict} name |
| 61 | Log ${name} |
| 62 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} name ${name} |
| 63 | ${test_result}= utils.compare_dict ${nodeDict} ${getJsonDict} |
| 64 | Should Be True ${test_result} |
| 65 | |
| 66 | Test Delete Node API |
| 67 | [Arguments] ${listIndex} |
| 68 | ${json_result}= restApi.ApiGet CH_CORE_NODES |
| 69 | ${json_result_list}= Get From Dictionary ${json_result} items |
| 70 | ${nodeList}= Get Variable Value ${nlist} |
| 71 | ${nodeDict}= utils.listToDict ${nodeList} ${listIndex} |
| 72 | ${name}= utils.getFieldValueFromDict ${nodeDict} name |
| 73 | Log ${name} |
| 74 | ${nodeDict}= utils.getDictFromListofDict ${json_result_list} name ${name} |
| 75 | Log ${nodeDict} |
| 76 | ${nodeId}= utils.getFieldValueFromDict ${nodeDict} id |
| 77 | Log ${nodeId} |
| 78 | ${test_result}= restApi.ApiChameleonDelete CH_CORE_NODES ${nodeId} |
| 79 | Should Be True ${test_result} |