Suchitra.Vemuri | 75dffd4 | 2016-12-20 15:35:25 -0800 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test suite for Sanity Test of Slice API |
| 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 | |
| 13 | *** Variables *** |
| 14 | ${USER} admin |
| 15 | ${PASSWORD} admin |
| 16 | ${PATHFILE} ${CURDIR}/data/Sanity_slice.json |
| 17 | |
| 18 | *** Test Cases *** TYPE LISTINDEX |
| 19 | Test Add Slice-1 CREATE 0 |
| 20 | |
| 21 | Test Get Slice-1 RETRIEVE 0 |
| 22 | |
Suchitra.Vemuri | 75dffd4 | 2016-12-20 15:35:25 -0800 | [diff] [blame] | 23 | Test Add Slice-2 CREATE 1 |
| 24 | |
| 25 | Test Get Slice-2 RETRIEVE 1 |
| 26 | |
Suchitra.Vemuri | 75dffd4 | 2016-12-20 15:35:25 -0800 | [diff] [blame] | 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 Instances ${listIndex} |
| 35 | Run Keyword If "${type}" == "RETRIEVE" Test Get Instances ${listIndex} |
| 36 | Run Keyword If "${type}" == "DELETE" Test Delete Instances ${listIndex} |
| 37 | |
| 38 | Test Post Instances |
| 39 | [Arguments] ${listIndex} |
| 40 | ${sliceList} = Get Variable Value ${sList} |
| 41 | ${sliceDict}= utils.listToDict ${sliceList} ${listIndex} |
| 42 | ${api_result}= restApi.ApiPost CORE_SANITY_SLICES ${sliceDict} |
| 43 | Should Be True ${api_result} |
| 44 | |
| 45 | Test Get Instances |
| 46 | [Arguments] ${listIndex} |
| 47 | ${json_result}= restApi.ApiGet CORE_SLICES |
| 48 | Log ${json_result} |
| 49 | ${sliceList}= Get Variable Value ${sList} |
| 50 | ${inputDict}= utils.listToDict ${sliceList} ${listIndex} |
| 51 | ${ID}= utils.getFieldValueFromDict ${inputDict} id |
| 52 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result} id ${ID} |
| 53 | ${test_result}= utils.compare_dict ${inputDict} ${getJsonDict} |
| 54 | Should Be True ${json_result} |
| 55 | |
| 56 | Test Delete Instances |
| 57 | [Arguments] ${listIndex} |
| 58 | ${json_getresult}= restApi.ApiGet CORE_SLICES |
| 59 | ${sliceList}= Get Variable Value ${sList} |
| 60 | ${sliceDict}= utils.listToDict ${sList} ${listIndex} |
| 61 | ${sliceName}= utils.getFieldValueFromDict ${sliceDict} name |
| 62 | Log ${sliceName} |
| 63 | ${getSliceDict}= utils.getDictFromListofDict ${json_getresult} name ${sliceName} |
| 64 | Log ${getSliceDict} |
| 65 | ${sliceID}= utils.getFieldValueFromDict ${getSliceDict} id |
| 66 | Log ${sliceID} |
| 67 | ${test_result}= restApi.ApiDelete CORE_SLICES ${sliceID} |
| 68 | Should be True ${test_result} |