| *** 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 *** |
| ${PATHFILE} ${CURDIR}/data/Ch_Flavors.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 CH_CORE_FLAVORS ${flavorDict} |
| Should Be True ${api_result} |
| |
| Test Get Flavors |
| [Arguments] ${listIndex} |
| ${json_result}= CORDRobot.ApiGet CH_CORE_FLAVORS |
| ${json_result_list}= Get From Dictionary ${json_result} items |
| Log ${json_result_list} |
| ${flavorList}= Get Variable Value ${vList} |
| ${inputDict}= CORDRobot.listToDict ${flavorList} ${listIndex} |
| ${flavorName}= CORDRobot.getFieldValueFromDict ${inputDict} name |
| ${getJsonDict}= CORDRobot.getDictFromListOfDict ${json_result_list} name ${flavorName} |
| ${test_result}= CORDRobot.compare_dict ${inputDict} ${getJsonDict} |
| Should Be True ${json_result} |
| |
| Test Delete Flavors |
| [Arguments] ${listIndex} |
| ${json_getresult}= CORDRobot.ApiGet CH_CORE_FLAVORS |
| ${json_getresult_list}= Get From Dictionary ${json_getresult} items |
| ${flavorList}= Get Variable Value ${vList} |
| ${flavorDict}= CORDRobot.listToDict ${vList} ${listIndex} |
| ${flavorName}= CORDRobot.getFieldValueFromDict ${flavorDict} name |
| Log ${flavorName} |
| ${getFlavorDict}= CORDRobot.getDictFromListofDict ${json_getresult_list} name ${flavorName} |
| Log ${getFlavorDict} |
| ${flavorID}= CORDRobot.getFieldValueFromDict ${getFlavorDict} id |
| Log ${flavorID} |
| ${test_result}= CORDRobot.ApiChameleonDelete CH_CORE_FLAVORS ${flavorID} |
| Should be True ${test_result} |