Suchitra Vemuri | f7410a9 | 2017-05-16 17:04:05 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test suite for Sanity Test of Instance API |
| 3 | Suite Setup Read InputFile |
| 4 | Test Template Verify Instance 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 *** |
Suchitra Vemuri | f7410a9 | 2017-05-16 17:04:05 -0700 | [diff] [blame] | 14 | ${PATHFILE} ${CURDIR}/data/Ch_SanityInstance.json |
| 15 | |
| 16 | *** Test Cases *** TYPE LISTINDEX |
| 17 | Test Add Instance-1 |
| 18 | CREATE 0 |
| 19 | |
| 20 | Test Get Instance-1 |
| 21 | RETRIEVE 0 |
| 22 | |
| 23 | Test Delete Instance-1 |
| 24 | DELETE 0 |
| 25 | |
| 26 | Test Add Instance-2 |
| 27 | CREATE 1 |
| 28 | |
| 29 | Test Get Instance-2 |
| 30 | RETRIEVE 1 |
| 31 | |
| 32 | Test Delete Instance-2 |
| 33 | DELETE 1 |
| 34 | |
| 35 | *** Keywords *** |
| 36 | Read InputFile |
| 37 | ${instanceList} = utils.jsonToList ${PATHFILE} InstanceInfo |
| 38 | Set Suite Variable ${iList} ${instanceList} |
| 39 | |
| 40 | Verify Instance API functionality |
| 41 | [Arguments] ${type} ${listIndex} |
| 42 | Run Keyword If "${type}" == "CREATE" Test Post Instances ${listIndex} |
| 43 | Run Keyword If "${type}" == "RETRIEVE" Test Get Instances ${listIndex} |
| 44 | Run Keyword If "${type}" == "DELETE" Test Delete Instances ${listIndex} |
| 45 | |
| 46 | Test Post Instances |
| 47 | [Arguments] ${listIndex} |
| 48 | ${instanceList} = Get Variable Value ${iList} |
| 49 | ${instanceDict}= utils.listToDict ${instanceList} ${listIndex} |
| 50 | ${api_result}= restApi.ApiPost CH_CORE_INSTANCES ${instanceDict} |
| 51 | Should Be True ${api_result} |
| 52 | |
| 53 | Test Get Instances |
| 54 | [Arguments] ${listIndex} |
| 55 | ${json_result}= restApi.ApiGet CH_CORE_INSTANCES |
| 56 | Log ${json_result} |
| 57 | ${json_result_list}= Get From Dictionary ${json_result} items |
| 58 | Log ${json_result_list} |
| 59 | ${instanceList}= Get Variable Value ${iList} |
| 60 | ${inputDict}= utils.listToDict ${instanceList} ${listIndex} |
| 61 | ${instanceName}= utils.getFieldValueFromDict ${inputDict} name |
| 62 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} name ${instanceName} |
| 63 | ${test_result}= utils.compare_dict ${inputDict} ${getJsonDict} |
| 64 | Should Be True ${json_result} |
| 65 | |
| 66 | Test Delete Instances |
| 67 | [Arguments] ${listIndex} |
| 68 | ${json_getresult}= restApi.ApiGet CH_CORE_INSTANCES |
| 69 | ${json_getresult_list}= Get From Dictionary ${json_getresult} items |
| 70 | ${instanceList}= Get Variable Value ${iList} |
| 71 | ${instanceDict}= utils.listToDict ${iList} ${listIndex} |
| 72 | ${instanceName}= utils.getFieldValueFromDict ${instanceDict} name |
| 73 | Log ${instanceName} |
| 74 | ${getInstanceDict}= utils.getDictFromListofDict ${json_getresult_list} name ${instanceName} |
| 75 | Log ${getInstanceDict} |
| 76 | ${instanceID}= utils.getFieldValueFromDict ${getInstanceDict} id |
| 77 | Log ${instanceID} |
| 78 | ${test_result}= restApi.ApiChameleonDelete CH_CORE_INSTANCES ${instanceID} |
| 79 | Should be True ${test_result} |