Suchitra Vemuri | 7dbf03c | 2018-04-25 23:06:23 -0700 | [diff] [blame^] | 1 | *** Settings *** |
| 2 | Documentation Test suite for VOLTDevice |
| 3 | Suite Setup Read InputFile |
| 4 | Test Template Verify VOLTDevice 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 | ${PATHFILE} ${CURDIR}/data/VOLTDevice.json |
| 15 | ${PATHFILE1} ${CURDIR}/data/PONPort.json |
| 16 | |
| 17 | *** Test Cases *** TYPE LISTINDEX |
| 18 | Test Create VOLTDevice-1 |
| 19 | CREATE 0 |
| 20 | Test Get VOLTDevice-1 |
| 21 | RETRIEVE 0 |
| 22 | Test Create PONPort-1 |
| 23 | PONCREATE 0 |
| 24 | |
| 25 | Test Get PONPort-1 |
| 26 | PONRETRIEVE 0 |
| 27 | #Test Delete VOLTDevice-1 |
| 28 | # DELETE 0 |
| 29 | Test Create VOLTDevice-2 |
| 30 | CREATE 1 |
| 31 | Test Get VOLTDevice-2 |
| 32 | RETRIEVE 1 |
| 33 | Test Create PONPort-2 |
| 34 | PONCREATE 1 |
| 35 | Test Get PONPort-2 |
| 36 | PONRETRIEVE 1 |
| 37 | #Test Delete VOLTDevice-2 |
| 38 | # DELETE 1 |
| 39 | Test Create VOLTDevice-3 |
| 40 | CREATE 2 |
| 41 | Test Get VOLTDevice-3 |
| 42 | RETRIEVE 2 |
| 43 | Test Create PONPort-3 |
| 44 | CREATE 2 |
| 45 | Test Get PONPort-3 |
| 46 | RETRIEVE 2 |
| 47 | #Test Delete VOLTDevice-3 |
| 48 | # DELETE 2 |
| 49 | |
| 50 | |
| 51 | *** Keywords *** |
| 52 | Read InputFile |
| 53 | ${voltDeviceList}= utils.jsonToList ${PATHFILE} VOLTDeviceInfo |
| 54 | Set Suite Variable ${dlist} ${voltDeviceList} |
| 55 | Set Global Variable ${VOLTDevice_Id} ${EMPTY} |
| 56 | ${PONPortList}= utils.jsonToList ${PATHFILE1} PONPortInfo |
| 57 | Set Suite Variable ${plist} ${PONPortList} |
| 58 | Set Suite Variable ${PONPort_Id} ${EMPTY} |
| 59 | |
| 60 | Verify VOLTDevice functionality |
| 61 | [Arguments] ${type} ${listIndex} |
| 62 | Run Keyword If "${type}" == "CREATE" Test Post VOLT Device API ${listIndex} |
| 63 | Run Keyword If "${type}" == "RETRIEVE" Test Get VOLT Device API ${listIndex} |
| 64 | Run Keyword If "${type}" == "DELETE" Test Delete VOLT Device API ${listIndex} |
| 65 | Run Keyword If "${type}" == "PONCREATE" Test Post PONPort API ${listIndex} |
| 66 | Run Keyword If "${type}" == "PONRETRIEVE" Test Get PONPort API ${listIndex} |
| 67 | |
| 68 | Test Post VOLT Device API |
| 69 | [Arguments] ${listIndex} |
| 70 | ${voltDeviceList} = Get Variable Value ${dlist} |
| 71 | ${voltDeviceDict}= utils.listToDict ${voltDeviceList} ${listIndex} |
| 72 | ${api_getResult}= restApi.ApiGet VOLT_SERVICE |
| 73 | ${voltServiceList}= Get From Dictionary ${api_getResult} items |
| 74 | ${voltServiceDict}= utils.getDictFromListOfDict ${voltServiceList} leaf_model_name VOLTService |
| 75 | ${VOLTService_Id}= Get From Dictionary ${voltServiceDict} id |
| 76 | ${voltDeviceDict}= utils.setFieldValueInDict ${voltDeviceDict} volt_service_id ${VOLTService_Id} |
| 77 | Log ${voltDeviceDict} |
| 78 | ${api_result_status} ${api_result_json}= restApi.ApiPostReturnJson VOLT_DEVICE ${voltDeviceDict} |
| 79 | Should Be True ${api_result_status} |
| 80 | ${VOLTDevice_Id}= Get From Dictionary ${api_result_json} id |
| 81 | Set Global Variable ${VOLTDevice_Id} |
| 82 | |
| 83 | Test Get VOLT Device API |
| 84 | [Arguments] ${listIndex} |
| 85 | Log ${VOLTDevice_Id} |
| 86 | ${json_result}= restApi.ApiChameleonGet VOLT_DEVICE ${VOLTDevice_Id} |
| 87 | Log ${json_result} |
| 88 | ${voltDeviceList} = Get Variable Value ${dlist} |
| 89 | ${voltDeviceDict}= utils.listToDict ${voltDeviceList} ${listIndex} |
| 90 | Log ${voltDeviceDict} |
| 91 | ${test_result}= utils.compare_dict ${voltDeviceDict} ${json_result} |
| 92 | Should Be True ${test_result} |
| 93 | |
| 94 | Test Post PONPort API |
| 95 | [Arguments] ${listIndex} |
| 96 | ${PONPortList} = Get Variable Value ${plist} |
| 97 | ${PONPortDict}= utils.listToDict ${PONPortList} ${listIndex} |
| 98 | ${PONPortDict}= utils.setFieldValueInDict ${PONPortDict} olt_device_id ${VOLTDevice_Id} |
| 99 | ${api_result_status} ${api_result_json}= restApi.ApiPostReturnJson PON_PORT ${PONPortDict} |
| 100 | Should Be True ${api_result_status} |
| 101 | ${PONPort_Id}= Get From Dictionary ${api_result_json} id |
| 102 | Set Global Variable ${PONPort_Id} |
| 103 | |
| 104 | Test Get PONPort API |
| 105 | [Arguments] ${listIndex} |
| 106 | Log ${PONPort_Id} |
| 107 | ${json_result}= restApi.ApiChameleonGet PON_PORT ${PONPort_Id} |
| 108 | Log ${json_result} |
| 109 | ${PONPortList} = Get Variable Value ${plist} |
| 110 | ${PONPortDict}= utils.listToDict ${PONPortList} ${listIndex} |
| 111 | Log ${PONPortDict} |
| 112 | ${test_result}= utils.compare_dict ${PONPortDict} ${json_result} |
| 113 | Should Be True ${test_result} |
| 114 | |
| 115 | Test Delete VOLT Device API |
| 116 | [Arguments] ${listIndex} |
| 117 | ${test_result}= restApi.ApiChameleonDelete VOLT_DEVICE ${VOLTDevice_Id} |
| 118 | Should Be True ${test_result} |