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