blob: 653086b84bac597135169b6c87f987e689466e2a [file] [log] [blame]
*** Settings ***
Documentation Test suite for VOLTDevice
Suite Setup Read InputFile
Test Template Verify VOLTDevice functionality
Library Collections
Library String
Library OperatingSystem
Library XML
Library RequestsLibrary
Library CORDRobot
Library ImportResource resources=CORDRobot
*** Variables ***
${PATHFILE} ${CURDIR}/data/VOLTDevice.json
${PATHFILE1} ${CURDIR}/data/PONPort.json
${PATHFILE2} ${CURDIR}/data/ONUDevice.json
*** Test Cases *** TYPE LISTINDEX
Test Create VOLTDevice-1
CREATE 0
Test Get VOLTDevice-1
RETRIEVE 0
Test Create PONPort-1
PONCREATE 0
Test Get PONPort-1
PONRETRIEVE 0
Test Create ONUDevice-1
ONUCREATE 0
Test Get ONUDevice-1
ONURETRIEVE 0
Test Create VOLTDevice-2
CREATE 1
Test Get VOLTDevice-2
RETRIEVE 1
Test Create PONPort-2
PONCREATE 1
Test Get PONPort-2
PONRETRIEVE 1
Test Create ONUDevice-2
ONUCREATE 1
Test Get ONUDevice-2
ONURETRIEVE 1
Test Create VOLTDevice-3
CREATE 2
Test Get VOLTDevice-3
RETRIEVE 2
Test Create PONPort-3
PONCREATE 2
Test Get PONPort-3
PONRETRIEVE 2
Test Create ONUDevice-3
ONUCREATE 2
Test Get ONUDevice-3
ONURETRIEVE 2
*** Keywords ***
Read InputFile
${voltDeviceList}= CORDRobot.jsonToList ${PATHFILE} VOLTDeviceInfo
Set Suite Variable ${dlist} ${voltDeviceList}
Set Global Variable ${VOLTDevice_Id} ${EMPTY}
${PONPortList}= CORDRobot.jsonToList ${PATHFILE1} PONPortInfo
Set Suite Variable ${plist} ${PONPortList}
Set Suite Variable ${PONPort_Id} ${EMPTY}
${ONUDeviceList}= CORDRobot.jsonToList ${PATHFILE2} ONUDeviceInfo
Set Suite Variable ${nlist} ${ONUDeviceList}
Set Suite Variable ${ONUDevice_Id} ${EMPTY}
Verify VOLTDevice functionality
[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}
Run Keyword If "${type}" == "DELETE" Test Delete VOLT Device API ${listIndex}
Run Keyword If "${type}" == "PONCREATE" Test Post PONPort API ${listIndex}
Run Keyword If "${type}" == "PONRETRIEVE" Test Get PONPort API ${listIndex}
Run Keyword If "${type}" == "ONUCREATE" Test Post ONUDevice API ${listIndex}
Run Keyword If "${type}" == "ONURETRIEVE" Test Get ONUDevice 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}
Test Post PONPort API
[Arguments] ${listIndex}
${PONPortList} = Get Variable Value ${plist}
${PONPortDict}= CORDRobot.listToDict ${PONPortList} ${listIndex}
${PONPortDict}= CORDRobot.setFieldValueInDict ${PONPortDict} olt_device_id ${VOLTDevice_Id}
${api_result_status} ${api_result_json}= CORDRobot.ApiPostReturnJson PON_PORT ${PONPortDict}
Should Be True ${api_result_status}
${PONPort_Id}= Get From Dictionary ${api_result_json} id
Set Global Variable ${PONPort_Id}
Test Get PONPort API
[Arguments] ${listIndex}
Log ${PONPort_Id}
${json_result}= CORDRobot.ApiChameleonGet PON_PORT ${PONPort_Id}
Log ${json_result}
${PONPortList} = Get Variable Value ${plist}
${PONPortDict}= CORDRobot.listToDict ${PONPortList} ${listIndex}
Log ${PONPortDict}
${test_result}= CORDRobot.compare_dict ${PONPortDict} ${json_result}
Should Be True ${test_result}
Test Post ONUDevice API
[Arguments] ${listIndex}
${ONUDeviceList}= Get Variable Value ${nlist}
${ONUDeviceDict}= CORDRobot.listToDict ${ONUDeviceList} ${listIndex}
${ONUDeviceDict}= CORDRobot.setFieldValueInDict ${ONUDeviceDict} pon_port_id ${PONPort_Id}
${api_result_status} ${api_result_json}= CORDRobot.ApiPostReturnJson ONU_DEVICE ${ONUDeviceDict}
Should Be True ${api_result_status}
${ONUDevice_Id}= Get From Dictionary ${api_result_json} id
Set Global Variable ${ONUDevice_Id}
Test Get ONUDevice API
[Arguments] ${listIndex}
Log ${ONUDevice_Id}
${json_result}= CORDRobot.ApiChameleonGet ONU_DEVICE ${ONUDevice_Id}
Log ${json_result}
${ONUDeviceList} = Get Variable Value ${nlist}
${ONUDeviceDict}= CORDRobot.listToDict ${ONUDeviceList} ${listIndex}
Log ${ONUDeviceDict}
${test_result}= CORDRobot.compare_dict ${ONUDeviceDict} ${json_result}
Should Be True ${test_result}
Test Delete VOLT Device API
[Arguments] ${listIndex}
${test_result}= CORDRobot.ApiChameleonDelete VOLT_DEVICE ${VOLTDevice_Id}
Should Be True ${test_result}