You Wang | 6f0fd1f | 2016-12-21 14:55:56 -0800 | [diff] [blame] | 1 | *** Settings *** |
You Wang | 123d694 | 2017-03-01 12:33:02 -0800 | [diff] [blame] | 2 | Documentation Test suite for Sanity Test of Node API |
You Wang | 6f0fd1f | 2016-12-21 14:55:56 -0800 | [diff] [blame] | 3 | Suite Setup Read InputFile |
| 4 | Test Template Verify Node 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/sanityNode.json |
| 17 | |
| 18 | *** Test Cases *** TYPE LISTINDEX |
| 19 | Test Post Node-1 CREATE 0 |
| 20 | |
| 21 | #Test Get Node-1 RETRIEVE 0 |
| 22 | |
| 23 | Test Delete Node-1 DELETE 0 |
| 24 | |
| 25 | Test Post Node-2 CREATE 1 |
| 26 | |
| 27 | #Test Get Node-2 RETRIEVE 1 |
| 28 | |
| 29 | Test Delete Node-2 DELETE 1 |
| 30 | |
| 31 | *** Keywords *** |
| 32 | Read InputFile |
| 33 | ${nodeList}= utils.jsonToList ${PATHFILE} NodeInfo |
| 34 | Set Suite Variable ${nlist} ${nodeList} |
| 35 | |
| 36 | Verify Node functionality |
| 37 | [Arguments] ${type} ${listIndex} |
| 38 | Run Keyword If "${type}" == "CREATE" Test Post Node API ${listIndex} |
| 39 | Run Keyword If "${type}" == "RETRIEVE" Test Get Node API ${listIndex} |
| 40 | Run Keyword If "${type}" == "DELETE" Test Delete Node API ${listIndex} |
| 41 | |
| 42 | Test Post Node API |
| 43 | [Arguments] ${listIndex} |
| 44 | ${nodeList}= Get Variable Value ${nlist} |
| 45 | ${nodeDict}= utils.listToDict ${nodeList} ${listIndex} |
| 46 | ${api_result}= restApi.ApiPost CORE_SANITY_NODES ${nodeDict} |
| 47 | Should Be True ${api_result} |
| 48 | |
| 49 | Test Get Node API |
| 50 | [Arguments] ${listIndex} |
| 51 | ${json_result}= restApi.ApiGet CORE_NODES |
| 52 | Log ${json_result} |
| 53 | ${nodeList}= Get Variable Value ${nlist} |
| 54 | ${nodeDict}= utils.listToDict ${nodeList} ${listIndex} |
| 55 | ${name}= utils.getFieldValueFromDict ${nodeDict} name |
| 56 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result} name ${name} |
| 57 | ${test_result}= utils.compare_dict ${nodeDict} ${getJsonDict} |
| 58 | Should Be True ${test_result} |
| 59 | |
| 60 | Test Delete Node API |
| 61 | [Arguments] ${listIndex} |
| 62 | ${json_result}= restApi.ApiGet CORE_NODES |
| 63 | ${nodeList}= Get Variable Value ${nlist} |
| 64 | ${nodeDict}= utils.listToDict ${nodeList} ${listIndex} |
| 65 | ${name}= utils.getFieldValueFromDict ${nodeDict} name |
| 66 | Log ${name} |
| 67 | ${nodeDict}= utils.getDictFromListofDict ${json_result} name ${name} |
| 68 | Log ${nodeDict} |
| 69 | ${nodeId}= utils.getFieldValueFromDict ${nodeDict} id |
| 70 | Log ${nodeId} |
| 71 | ${test_result}= restApi.ApiDelete CORE_NODES ${nodeId} |
| 72 | Should Be True ${test_result} |