blob: 2b2e7bd7ea3a142e648f933e9d4efdd89df6a35e [file] [log] [blame]
*** Settings ***
Documentation Test suite for volt Tenant Verification
Suite Setup Read InputFile
Test Template Verify volt Tenant Functionality
Library Collections
Library String
Library OperatingSystem
Library XML
Library RequestsLibrary
Library CORDRobot
Library ImportResource resources=CORDRobot
*** Variables ***
${USER} admin
${PASSWORD} admin
${PATHFILE} ${CURDIR}/data/VoltTenant.json
${PATHFILE2} ${CURDIR}/data/putVoltTenant.json
*** Test Cases *** TYPE LISTINDEX
Test volt Tenant-1 CREATE 0
Test volt Tenant-2 CREATE 1
Test volt Tenant-3 CREATE 2
*** Keywords ***
Read InputFile
${voltList} = CORDRobot.jsonToList ${PATHFILE} voltSubscriberInfo
Set Suite Variable ${vlist} ${voltList}
${putvoltList}= CORDRobot.jsonToList ${PATHFILE2} voltSubscriberInfo
Set Suite Variable ${putList} ${putvoltList}
Verify volt Tenant Functionality
[Arguments] ${type} ${listIndex}
Run Keyword If "${type}" == "CREATE" Test Post volt Tenant API ${listIndex}
Test Post volt Tenant API
[Arguments] ${listIndex}
${voltTenantList} = Get Variable Value ${vlist}
${voltTenantDict}= CORDRobot.listToDict ${voltTenantList} ${listIndex}
${voltDict}= Get From Dictionary ${voltTenantDict} voltTenant
${account_num}= Get From Dictionary ${voltTenantDict} account_num
${get_result}= CORDRobot.ApiGet TENANT_SUBSCRIBER
${subscriberDict}= CORDRobot.getDictFromListofDict ${get_result} account_num ${account_num}
${subscriberID}= CORDRobot.getFieldValueFromDict ${subscriberDict} id
${updatedVoltDict}= CORDRobot.setFieldValueInDict ${voltDict} subscriber ${subscriberID}
${api_result}= CORDRobot.ApiPost TENANT_VOLT ${updatedVoltDict}
Should Be True ${api_result}
# Verifying Get operation after POST
${getVolt_result}= CORDRobot.ApiGet TENANT_VOLT
${getJsonDict}= CORDRobot.getDictFromListOfDict ${getVolt_result} subscriber ${subscriberID}
${test_result}= CORDRobot.compare_dict ${voltDict} ${getJsonDict}
Should Be True ${test_result}
# Verifying PUT operation
${putvoltList}= Get Variable Value ${putList}
${putVoltDict}= CORDRobot.listToDict ${putvoltList} ${listIndex}
${putvoltTenantDict}= Get From Dictionary ${putVoltDict} voltTenant
${voltID}= CORDRobot.getFieldValueFromDict ${getJsonDict} id
${put_result}= CORDRobot.ApiPut TENANT_VOLT ${putvoltTenantDict} ${voltID}
Should Be True ${put_result}
# Verifying Get after PUT operation
${getVolt_afterPut}= CORDRobot.ApiGet TENANT_VOLT
${getVoltDict}= CORDRobot.getDictFromListofDict ${getVolt_afterPut} id ${voltID}
${result_afterPut}= CORDRobot.compare_dict ${putvoltTenantDict} ${getVoltDict}
Should Be True ${result_afterPut}