blob: f0061e9a6b8c0a45d4d33c78ea7f79120c1560f7 [file] [log] [blame]
*** Settings ***
Documentation Test suite for configuring OLT device using REST APIs
Suite Setup Read InputFile
Test Template Configuring Real OLT device
Library Collections
Library String
Library OperatingSystem
Library XML
Library RequestsLibrary
Library CORDRobot
Library ImportResource resources=CORDRobot
*** Variables ***
${PATHFILE} ${CURDIR}/data/RealOLTDevice.json
*** Test Cases *** TYPE LISTINDEX
Test Create VOLTDevice-1
CREATE 0
Test Get VOLTDevice-1
RETRIEVE 0
*** Keywords ***
Read InputFile
${voltDeviceList}= CORDRobot.jsonToList ${PATHFILE} VOLTDeviceInfo
Set Suite Variable ${dlist} ${voltDeviceList}
Set Global Variable ${VOLTDevice_Id} ${EMPTY}
Configuring Real OLT device
[Arguments] ${type} ${listIndex}
Run Keyword If "${type}" == "CREATE" Test Post VOLT Device API ${listIndex}
Run Keyword If "${type}" == "RETRIEVE" Test Get VOLT Device API ${listIndex}
Test Post VOLT Device API
[Arguments] ${listIndex}
${voltDeviceList} = Get Variable Value ${dlist}
${voltDeviceDict}= CORDRobot.listToDict ${voltDeviceList} ${listIndex}
${api_getResult}= CORDRobot.ApiGet VOLT_SERVICE
${voltServiceList}= Get From Dictionary ${api_getResult} items
${voltServiceDict}= CORDRobot.getDictFromListOfDict ${voltServiceList} leaf_model_name VOLTService
${VOLTService_Id}= Get From Dictionary ${voltServiceDict} id
${voltDeviceDict}= CORDRobot.setFieldValueInDict ${voltDeviceDict} volt_service_id ${VOLTService_Id}
Log ${voltDeviceDict}
${api_result_status} ${api_result_json}= CORDRobot.ApiPostReturnJson VOLT_DEVICE ${voltDeviceDict}
Should Be True ${api_result_status}
${VOLTDevice_Id}= Get From Dictionary ${api_result_json} id
Set Global Variable ${VOLTDevice_Id}
Test Get VOLT Device API
[Arguments] ${listIndex}
Log ${VOLTDevice_Id}
${json_result}= CORDRobot.ApiChameleonGet VOLT_DEVICE ${VOLTDevice_Id}
Log ${json_result}
${voltDeviceList} = Get Variable Value ${dlist}
${voltDeviceDict}= CORDRobot.listToDict ${voltDeviceList} ${listIndex}
Log ${voltDeviceDict}
${test_result}= CORDRobot.compare_dict ${voltDeviceDict} ${json_result}
Should Be True ${test_result}