voltTenant tests: enhanced subscriber tests
Change-Id: Id28389dc9d77c5e5eb2b76cbd81a1c29fa8de17f
diff --git a/src/test/cord-api/Tests/VoltTenant.txt b/src/test/cord-api/Tests/VoltTenant.txt
new file mode 100644
index 0000000..136cae6
--- /dev/null
+++ b/src/test/cord-api/Tests/VoltTenant.txt
@@ -0,0 +1,65 @@
+*** 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 ../Framework/utils/utils.py
+Library ../Framework/restApi.py
+
+*** 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} = utils.jsonToList ${PATHFILE} voltSubscriberInfo
+ Set Suite Variable ${vlist} ${voltList}
+ ${putvoltList}= utils.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}= utils.listToDict ${voltTenantList} ${listIndex}
+ ${voltDict}= Get From Dictionary ${voltTenantDict} voltTenant
+ ${account_num}= Get From Dictionary ${voltTenantDict} account_num
+ ${get_result}= restApi.ApiGet TENANT_SUBSCRIBER
+ ${subscriberDict}= utils.getDictFromListofDict ${get_result} account_num ${account_num}
+ ${subscriberID}= utils.getFieldValueFromDict ${subscriberDict} id
+ ${updatedVoltDict}= utils.setFieldValueInDict ${voltDict} subscriber ${subscriberID}
+ ${api_result}= restApi.ApiPost TENANT_VOLT ${updatedVoltDict}
+ Should Be True ${api_result}
+ # Verifying Get operation after POST
+ ${getVolt_result}= restApi.ApiGet TENANT_VOLT
+ ${getJsonDict}= utils.getDictFromListOfDict ${getVolt_result} subscriber ${subscriberID}
+ ${test_result}= utils.compare_dict ${voltDict} ${getJsonDict}
+ Should Be True ${test_result}
+ # Verifying PUT operation
+ ${putvoltList}= Get Variable Value ${putList}
+ ${putVoltDict}= utils.listToDict ${putvoltList} ${listIndex}
+ ${putvoltTenantDict}= Get From Dictionary ${putVoltDict} voltTenant
+ ${voltID}= utils.getFieldValueFromDict ${getJsonDict} id
+ ${put_result}= restApi.ApiPut TENANT_VOLT ${putvoltTenantDict} ${voltID}
+ Should Be True ${put_result}
+ # Verifying Get after PUT operation
+ ${getVolt_afterPut}= restApi.ApiGet TENANT_VOLT
+ ${getVoltDict}= utils.getDictFromListofDict ${getVolt_afterPut} id ${voltID}
+ ${result_afterPut}= utils.compare_dict ${putvoltTenantDict} ${getVoltDict}
+ Should Be True ${result_afterPut}