blob: 2815a73a3280be18c76785b44b20464f6280e7a2 [file] [log] [blame]
*** Settings ***
Documentation Test suite for Sanity Test of Flavors API
Suite Setup Read InputFile
Test Template Verify Flavor API 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/SanityFlavors.json
*** Test Cases *** TYPE LISTINDEX
Test Add Flavor-1 CREATE 0
Test Get Flavor-1 RETRIEVE 0
Test Delete Flavor-1
DELETE 0
Test Add Flavor-2 CREATE 1
Test Get Flavor-2 RETRIEVE 1
Test Delete Flavor-2
DELETE 1
*** Keywords ***
Read InputFile
${flavorList} = CORDRobot.jsonToList ${PATHFILE} flavorsInfo
Set Suite Variable ${vList} ${flavorList}
Verify Flavor API functionality
[Arguments] ${type} ${listIndex}
Run Keyword If "${type}" == "CREATE" Test Post Flavors ${listIndex}
Run Keyword If "${type}" == "RETRIEVE" Test Get Flavors ${listIndex}
Run Keyword If "${type}" == "DELETE" Test Delete Flavors ${listIndex}
Test Post Flavors
[Arguments] ${listIndex}
${flavorList} = Get Variable Value ${vList}
${flavorDict}= CORDRobot.listToDict ${flavorList} ${listIndex}
${api_result}= CORDRobot.ApiPost CORE_FLAVORS ${flavorDict}
Should Be True ${api_result}
Test Get Flavors
[Arguments] ${listIndex}
${json_result}= CORDRobot.ApiGet CORE_FLAVORS
Log ${json_result}
${flavorList}= Get Variable Value ${vList}
${inputDict}= CORDRobot.listToDict ${flavorList} ${listIndex}
${flavorName}= CORDRobot.getFieldValueFromDict ${inputDict} name
${getJsonDict}= CORDRobot.getDictFromListOfDict ${json_result} name ${flavorName}
${test_result}= CORDRobot.compare_dict ${inputDict} ${getJsonDict}
Should Be True ${json_result}
Test Delete Flavors
[Arguments] ${listIndex}
${json_getresult}= CORDRobot.ApiGet CORE_FLAVORS
${flavorList}= Get Variable Value ${vList}
${flavorDict}= CORDRobot.listToDict ${vList} ${listIndex}
${flavorName}= CORDRobot.getFieldValueFromDict ${flavorDict} name
Log ${flavorName}
${getFlavorDict}= CORDRobot.getDictFromListofDict ${json_getresult} name ${flavorName}
Log ${getFlavorDict}
${flavorID}= CORDRobot.getFieldValueFromDict ${getFlavorDict} id
Log ${flavorID}
${test_result}= CORDRobot.ApiDelete CORE_FLAVORS ${flavorID}
Should be True ${test_result}