blob: 9b6817f7701f61222cb38db156845e034b93dd92 [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 ***
${USER} admin
${PASSWORD} admin
${PATHFILE} ${CURDIR}/data/Service.json
${PATHFILE2} ${CURDIR}/data/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 CORE_SERVICES ${serviceDict}
Should Be True ${api_result}
Test Get Service API
[Arguments] ${listIndex}
${json_result}= CORDRobot.ApiGet CORE_SERVICES
Log ${json_result}
${serviceList}= Get Variable Value ${slist}
${serviceDict}= CORDRobot.listToDict ${serviceList} ${listIndex}
${name}= CORDRobot.getFieldValueFromDict ${serviceDict} name
${getJsonDict}= CORDRobot.getDictFromListOfDict ${json_result} name ${name}
${test_result}= CORDRobot.compare_dict ${serviceDict} ${getJsonDict}
Should Be True ${test_result}
Test Edit Service API
[Arguments] ${listIndex}
${get_result}= CORDRobot.ApiGet CORE_SERVICES
${putServiceList}= Get Variable Value ${putList}
${putServiceDict}= CORDRobot.listToDict ${putServiceList} ${listIndex}
${name}= CORDRobot.getFieldValueFromDict ${putServiceDict} name
${serviceDict}= CORDRobot.getDictFromListofDict ${get_result} name ${name}
${serviceID}= CORDRobot.getFieldValueFromDict ${serviceDict} id
${api_result}= CORDRobot.ApiPut CORE_SERVICES ${putServiceDict} ${serviceID}
Should Be True ${api_result}
${getResultAfterPut}= CORDRobot.ApiGet 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 CORE_SERVICES
${serviceList}= Get Variable Value ${slist}
${serviceDict}= CORDRobot.listToDict ${serviceList} ${listIndex}
${name}= CORDRobot.getFieldValueFromDict ${serviceDict} name
Log ${name}
${serviceDict}= CORDRobot.getDictFromListofDict ${json_result} name ${name}
Log ${serviceDict}
${serviceId}= CORDRobot.getFieldValueFromDict ${serviceDict} id
Log ${serviceId}
${test_result}= CORDRobot.ApiDelete CORE_SERVICES ${serviceId}
Should Be True ${test_result}