Suchitra Vemuri | f7410a9 | 2017-05-16 17:04:05 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test suite for Slice API verification |
| 3 | Suite Setup Read InputFile |
| 4 | Test Template Verify Slice 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_Slice.json |
| 16 | ${IP} ${SERVER_IP} |
| 17 | ${PORT} ${SERVER_PORT} |
| 18 | |
| 19 | *** Test Cases *** TYPE LISTINDEX |
| 20 | Test Add Slice-1 CREATE 0 |
| 21 | |
| 22 | Test Get Slice-1 RETRIEVE 0 |
| 23 | |
| 24 | Test Delete Slice-1 |
| 25 | DELETE 0 |
| 26 | |
| 27 | *** Keywords *** |
| 28 | Read InputFile |
| 29 | ${sliceList} = utils.jsonToList ${PATHFILE} SliceInfo |
| 30 | Set Suite Variable ${sList} ${sliceList} |
| 31 | |
| 32 | Verify Slice API functionality |
| 33 | [Arguments] ${type} ${listIndex} |
| 34 | Run Keyword If "${type}" == "CREATE" Test Post Slice API ${listIndex} |
| 35 | Run Keyword If "${type}" == "RETRIEVE" Test Get Slice API ${listIndex} |
| 36 | Run Keyword If "${type}" == "DELETE" Test Delete Slice API ${listIndex} |
| 37 | |
| 38 | Test Post Slice API |
| 39 | [Arguments] ${listIndex} |
| 40 | ${sliceList} = Get Variable Value ${sList} |
| 41 | ${sliceDict}= utils.listToDict ${sliceList} ${listIndex} |
| 42 | ${api_result}= restApi.ApiPost CH_CORE_SLICES ${sliceDict} |
| 43 | Should Be True ${api_result} |
| 44 | |
| 45 | Test Get Slice API |
| 46 | [Arguments] ${listIndex} |
| 47 | ${json_result}= restApi.ApiGet CH_CORE_SLICES |
| 48 | ${json_result_list}= Get From Dictionary ${json_result} items |
| 49 | Log ${json_result_list} |
| 50 | ${sliceList}= Get Variable Value ${sList} |
| 51 | ${sliceDict}= utils.listToDict ${sliceList} ${listIndex} |
| 52 | ${sliceName}= Get From Dictionary ${sliceDict} name |
| 53 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} name ${sliceName} |
| 54 | ${test_result}= utils.compare_dict ${sliceDict} ${getJsonDict} |
| 55 | Should Be True ${json_result} |
| 56 | |
| 57 | Test Delete Slice API |
| 58 | [Arguments] ${listIndex} |
| 59 | ${json_getresult}= restApi.ApiGet CH_CORE_SLICES |
| 60 | ${json_getresult_list}= Get From Dictionary ${json_getresult} items |
| 61 | ${sliceList}= Get Variable Value ${sList} |
| 62 | ${sliceDict}= utils.listToDict ${sList} ${listIndex} |
| 63 | ${sliceName}= utils.getFieldValueFromDict ${sliceDict} name |
| 64 | Log ${sliceName} |
| 65 | ${getSliceDict}= utils.getDictFromListofDict ${json_getresult_list} name ${sliceName} |
| 66 | Log ${getSliceDict} |
| 67 | ${sliceID}= utils.getFieldValueFromDict ${getSliceDict} id |
| 68 | Log ${sliceID} |
| 69 | ${test_result}= restApi.ApiChameleonDelete CH_CORE_SLICES ${sliceID} |
| 70 | Should be True ${test_result} |