Suchitra Vemuri | 0f3dd09 | 2018-07-10 17:24:56 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test suite for configuring OLT device using REST APIs |
| 3 | Suite Setup Read InputFile |
| 4 | Test Template Configuring Real OLT device |
| 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/RealOLTDevice.json |
| 15 | |
| 16 | *** Test Cases *** TYPE LISTINDEX |
| 17 | Test Create VOLTDevice-1 |
| 18 | CREATE 0 |
| 19 | Test Get VOLTDevice-1 |
| 20 | RETRIEVE 0 |
| 21 | |
| 22 | *** Keywords *** |
| 23 | Read InputFile |
| 24 | ${voltDeviceList}= utils.jsonToList ${PATHFILE} VOLTDeviceInfo |
| 25 | Set Suite Variable ${dlist} ${voltDeviceList} |
| 26 | Set Global Variable ${VOLTDevice_Id} ${EMPTY} |
| 27 | |
| 28 | Configuring Real OLT device |
| 29 | [Arguments] ${type} ${listIndex} |
| 30 | Run Keyword If "${type}" == "CREATE" Test Post VOLT Device API ${listIndex} |
| 31 | Run Keyword If "${type}" == "RETRIEVE" Test Get VOLT Device API ${listIndex} |
| 32 | |
| 33 | Test Post VOLT Device API |
| 34 | [Arguments] ${listIndex} |
| 35 | ${voltDeviceList} = Get Variable Value ${dlist} |
| 36 | ${voltDeviceDict}= utils.listToDict ${voltDeviceList} ${listIndex} |
| 37 | ${api_getResult}= restApi.ApiGet VOLT_SERVICE |
| 38 | ${voltServiceList}= Get From Dictionary ${api_getResult} items |
| 39 | ${voltServiceDict}= utils.getDictFromListOfDict ${voltServiceList} leaf_model_name VOLTService |
| 40 | ${VOLTService_Id}= Get From Dictionary ${voltServiceDict} id |
| 41 | ${voltDeviceDict}= utils.setFieldValueInDict ${voltDeviceDict} volt_service_id ${VOLTService_Id} |
| 42 | Log ${voltDeviceDict} |
| 43 | ${api_result_status} ${api_result_json}= restApi.ApiPostReturnJson VOLT_DEVICE ${voltDeviceDict} |
| 44 | Should Be True ${api_result_status} |
| 45 | ${VOLTDevice_Id}= Get From Dictionary ${api_result_json} id |
| 46 | Set Global Variable ${VOLTDevice_Id} |
| 47 | |
| 48 | Test Get VOLT Device API |
| 49 | [Arguments] ${listIndex} |
| 50 | Log ${VOLTDevice_Id} |
| 51 | ${json_result}= restApi.ApiChameleonGet VOLT_DEVICE ${VOLTDevice_Id} |
| 52 | Log ${json_result} |
| 53 | ${voltDeviceList} = Get Variable Value ${dlist} |
| 54 | ${voltDeviceDict}= utils.listToDict ${voltDeviceList} ${listIndex} |
| 55 | Log ${voltDeviceDict} |
| 56 | ${test_result}= utils.compare_dict ${voltDeviceDict} ${json_result} |
| 57 | Should Be True ${test_result} |