*** Settings ***
Documentation     Test suite for volt Tenant Verification - Chameleon API
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 ***
${PATHFILE}       ${CURDIR}/data/Ch_VoltTenant.json
${PATHFILE2}      ${CURDIR}/data/Ch_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
    ${name}=    Get From Dictionary    ${voltDict}   name 
    ${postResult}=    restApi.ApiPost    VOLT_TENANT    ${voltDict}
    # Verifying Get Operation after POST
    ${getVolt_result}=    restApi.ApiGet    VOLT_TENANT
    ${getVolt_result_list}=    Get From Dictionary    ${getVolt_result}    items
    ${getJsonDict}=    utils.getDictFromListOfDict    ${getVolt_result_list}    name    ${name}
    ${test_result}=    utils.compare_dict    ${voltDict}    ${getJsonDict}
    Should Be True    ${test_result}
