blob: 6a933611ce89c471f4087ada14ee38c7e9c36c59 [file] [log] [blame]
*** 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 Instances ${listIndex}
Run Keyword If "${type}" == "RETRIEVE" Test Get Instances ${listIndex}
Run Keyword If "${type}" == "DELETE" Test Delete Instances ${listIndex}
Test Post Instances
[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 Instances
[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 Instances
[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}