blob: 203dd9a313ecae769c6a5d9078bb1ae3d3dd0fbf [file] [log] [blame]
*** Settings ***
Documentation Test suite for Service verification
Suite Setup Read InputFile
Test Template Verify Service functionality
Library Collections
Library String
Library OperatingSystem
Library XML
Library RequestsLibrary
Library CORDRobot
Library ImportResource resources=CORDRobot
*** Variables ***
${PATHFILE} ${CURDIR}/data/Ch_Service.json
${PATHFILE2} ${CURDIR}/data/Ch_putService.json
*** Test Cases *** TYPE LISTINDEX
Test Post Service-1
CREATE 0
Test Get Service-1 RETRIEVE 0
Test Edit Service-1
PUT 0
Test Delete Service-1
DELETE 0
Test Post Service-2
CREATE 1
Test Get Service-2 RETRIEVE 1
Test Edit Service-2
PUT 1
Test Delete Service-2
DELETE 1
*** Keywords ***
Read InputFile
${serviceList}= CORDRobot.jsonToList ${PATHFILE} ServiceInfo
Set Suite Variable ${slist} ${serviceList}
${putServiceList}= CORDRobot.jsonToList ${PATHFILE2} ServiceInfo
Set Suite Variable ${putList} ${putServiceList}
Verify Service functionality
[Arguments] ${type} ${listIndex}
Run Keyword If "${type}" == "CREATE" Test Post Service API ${listIndex}
Run Keyword If "${type}" == "RETRIEVE" Test Get Service API ${listIndex}
Run Keyword If "${type}" == "PUT" Test Edit Service API ${listIndex}
Run Keyword If "${type}" == "DELETE" Test Delete Service API ${listIndex}
Test Post Service API
[Arguments] ${listIndex}
${serviceList} = Get Variable Value ${slist}
${serviceDict}= CORDRobot.listToDict ${serviceList} ${listIndex}
${api_result}= CORDRobot.ApiPost CH_CORE_SERVICES ${serviceDict}
Should Be True ${api_result}
Test Get Service API
[Arguments] ${listIndex}
${json_result}= CORDRobot.ApiGet CH_CORE_SERVICES
${json_result_list}= Get From Dictionary ${json_result} items
Log ${json_result_list}
Log ${json_result}
${serviceList}= Get Variable Value ${slist}
${serviceDict}= CORDRobot.listToDict ${serviceList} ${listIndex}
${name}= CORDRobot.getFieldValueFromDict ${serviceDict} name
${getJsonDict}= CORDRobot.getDictFromListOfDict ${json_result_list} name ${name}
${test_result}= CORDRobot.compare_dict ${serviceDict} ${getJsonDict}
Should Be True ${test_result}
Test Edit Service API
[Arguments] ${listIndex}
${get_result}= CORDRobot.ApiGet CH_CORE_SERVICES
${get_result_list}= Get From Dictionary ${get_result} items
${putServiceList}= Get Variable Value ${putList}
${putServiceDict}= CORDRobot.listToDict ${putServiceList} ${listIndex}
${name}= CORDRobot.getFieldValueFromDict ${putServiceDict} name
${serviceDict}= CORDRobot.getDictFromListofDict ${get_result_list} name ${name}
${serviceID}= CORDRobot.getFieldValueFromDict ${serviceDict} id
${api_result}= CORDRobot.ApiChameleonPut CH_CORE_SERVICES ${putServiceDict} ${serviceID}
Should Be True ${api_result}
${getResultAfterPut}= CORDRobot.ApiChameleonGet CH_CORE_SERVICES ${serviceID}
${test_result}= CORDRobot.compare_dict ${putServiceDict} ${getResultAfterPut}
Should Be True ${test_result}
Test Delete Service API
[Arguments] ${listIndex}
${json_result}= CORDRobot.ApiGet CH_CORE_SERVICES
${json_result_list}= Get From Dictionary ${json_result} items
${serviceList}= Get Variable Value ${slist}
${serviceDict}= CORDRobot.listToDict ${serviceList} ${listIndex}
${name}= CORDRobot.getFieldValueFromDict ${serviceDict} name
Log ${name}
${serviceDict}= CORDRobot.getDictFromListofDict ${json_result_list} name ${name}
Log ${serviceDict}
${serviceId}= CORDRobot.getFieldValueFromDict ${serviceDict} id
Log ${serviceId}
${test_result}= CORDRobot.ApiChameleonDelete CH_CORE_SERVICES ${serviceId}
Should Be True ${test_result}