| *** Settings *** |
| Documentation Test suite for Sanity Test of Slice API |
| Suite Setup Read InputFile |
| Test Template Verify Slice API functionality |
| Library Collections |
| Library String |
| Library OperatingSystem |
| Library XML |
| Library RequestsLibrary |
| Library ../Framework/utils/utils.py |
| Library ../Framework/restApi.py |
| |
| *** Variables *** |
| ${USER} admin |
| ${PASSWORD} admin |
| ${PATHFILE} ${CURDIR}/data/Sanity_slice.json |
| |
| *** Test Cases *** TYPE LISTINDEX |
| Test Add Slice-1 CREATE 0 |
| |
| Test Get Slice-1 RETRIEVE 0 |
| |
| *** Keywords *** |
| Read InputFile |
| ${sliceList} = utils.jsonToList ${PATHFILE} sliceInfo |
| Set Suite Variable ${sList} ${sliceList} |
| |
| Verify Slice API functionality |
| [Arguments] ${type} ${listIndex} |
| Run Keyword If "${type}" == "CREATE" Test Post Slices ${listIndex} |
| Run Keyword If "${type}" == "RETRIEVE" Test Get Slices ${listIndex} |
| Run Keyword If "${type}" == "DELETE" Test Delete Slices ${listIndex} |
| |
| Test Post Slices |
| [Arguments] ${listIndex} |
| ${sliceList} = Get Variable Value ${sList} |
| ${sliceDict}= utils.listToDict ${sliceList} ${listIndex} |
| ${api_result}= restApi.ApiPost CORE_SANITY_SLICES ${sliceDict} |
| Should Be True ${api_result} |
| |
| Test Get Slices |
| [Arguments] ${listIndex} |
| ${json_result}= restApi.ApiGet CORE_SLICES |
| Log ${json_result} |
| ${sliceList}= Get Variable Value ${sList} |
| ${inputDict}= utils.listToDict ${sliceList} ${listIndex} |
| ${ID}= utils.getFieldValueFromDict ${inputDict} id |
| ${getJsonDict}= utils.getDictFromListOfDict ${json_result} id ${ID} |
| ${test_result}= utils.compare_dict ${inputDict} ${getJsonDict} |
| Should Be True ${json_result} |
| |
| Test Delete Slices |
| [Arguments] ${listIndex} |
| ${json_getresult}= restApi.ApiGet CORE_SLICES |
| ${sliceList}= Get Variable Value ${sList} |
| ${sliceDict}= utils.listToDict ${sList} ${listIndex} |
| ${sliceName}= utils.getFieldValueFromDict ${sliceDict} name |
| Log ${sliceName} |
| ${getSliceDict}= utils.getDictFromListofDict ${json_getresult} name ${sliceName} |
| Log ${getSliceDict} |
| ${sliceID}= utils.getFieldValueFromDict ${getSliceDict} id |
| Log ${sliceID} |
| ${test_result}= restApi.ApiDelete CORE_SLICES ${sliceID} |
| Should be True ${test_result} |