blob: 70b2d0df4cf5aedd2221b56910ac56dc42f0e3b1 [file] [log] [blame]
*** Settings ***
Documentation Test suite for Sanity Test of Instance API
Suite Setup Read InputFile
Test Template Verify Instance API functionality
Library Collections
Library String
Library OperatingSystem
Library XML
Library RequestsLibrary
Library CORDRobot
Library ImportResource resources=CORDRobot
*** Variables ***
${PATHFILE} ${CURDIR}/data/Ch_SanityInstance.json
*** Test Cases *** TYPE LISTINDEX
Test Add Instance-1
CREATE 0
Test Get Instance-1
RETRIEVE 0
Test Delete Instance-1
DELETE 0
Test Add Instance-2
CREATE 1
Test Get Instance-2
RETRIEVE 1
Test Delete Instance-2
DELETE 1
*** Keywords ***
Read InputFile
${instanceList} = CORDRobot.jsonToList ${PATHFILE} InstanceInfo
Set Suite Variable ${iList} ${instanceList}
Verify Instance API functionality
[Arguments] ${type} ${listIndex}
Run Keyword If "${type}" == "CREATE" Test Post Instances ${listIndex}
Run Keyword If "${type}" == "RETRIEVE" Test Get Instances ${listIndex}
Run Keyword If "${type}" == "DELETE" Test Delete Instances ${listIndex}
Test Post Instances
[Arguments] ${listIndex}
${instanceList} = Get Variable Value ${iList}
${instanceDict}= CORDRobot.listToDict ${instanceList} ${listIndex}
${api_result}= CORDRobot.ApiPost CH_CORE_INSTANCES ${instanceDict}
Should Be True ${api_result}
Test Get Instances
[Arguments] ${listIndex}
${json_result}= CORDRobot.ApiGet CH_CORE_INSTANCES
Log ${json_result}
${json_result_list}= Get From Dictionary ${json_result} items
Log ${json_result_list}
${instanceList}= Get Variable Value ${iList}
${inputDict}= CORDRobot.listToDict ${instanceList} ${listIndex}
${instanceName}= CORDRobot.getFieldValueFromDict ${inputDict} name
${getJsonDict}= CORDRobot.getDictFromListOfDict ${json_result_list} name ${instanceName}
${test_result}= CORDRobot.compare_dict ${inputDict} ${getJsonDict}
Should Be True ${json_result}
Test Delete Instances
[Arguments] ${listIndex}
${json_getresult}= CORDRobot.ApiGet CH_CORE_INSTANCES
${json_getresult_list}= Get From Dictionary ${json_getresult} items
${instanceList}= Get Variable Value ${iList}
${instanceDict}= CORDRobot.listToDict ${iList} ${listIndex}
${instanceName}= CORDRobot.getFieldValueFromDict ${instanceDict} name
Log ${instanceName}
${getInstanceDict}= CORDRobot.getDictFromListofDict ${json_getresult_list} name ${instanceName}
Log ${getInstanceDict}
${instanceID}= CORDRobot.getFieldValueFromDict ${getInstanceDict} id
Log ${instanceID}
${test_result}= CORDRobot.ApiChameleonDelete CH_CORE_INSTANCES ${instanceID}
Should be True ${test_result}