Suchitra Vemuri | f7410a9 | 2017-05-16 17:04:05 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test suite for Service verification |
| 3 | Suite Setup Read InputFile |
| 4 | Test Template Verify Service functionality |
| 5 | Library Collections |
| 6 | Library String |
| 7 | Library OperatingSystem |
| 8 | Library XML |
| 9 | Library RequestsLibrary |
| 10 | Library ../Framework/utils/utils.py |
| 11 | Library ../Framework/restApi.py |
| 12 | |
| 13 | *** Variables *** |
| 14 | ${USER} admin |
| 15 | ${PASSWORD} admin |
| 16 | ${PATHFILE} ${CURDIR}/data/Ch_Service.json |
| 17 | ${PATHFILE2} ${CURDIR}/data/Ch_putService.json |
| 18 | |
| 19 | *** Test Cases *** TYPE LISTINDEX |
| 20 | Test Post Service-1 |
| 21 | CREATE 0 |
| 22 | |
| 23 | Test Get Service-1 RETRIEVE 0 |
| 24 | |
| 25 | Test Edit Service-1 |
| 26 | PUT 0 |
| 27 | |
| 28 | Test Delete Service-1 |
| 29 | DELETE 0 |
| 30 | |
| 31 | Test Post Service-2 |
| 32 | CREATE 1 |
| 33 | |
| 34 | Test Get Service-2 RETRIEVE 1 |
| 35 | |
| 36 | Test Edit Service-2 |
| 37 | PUT 1 |
| 38 | |
| 39 | Test Delete Service-2 |
| 40 | DELETE 1 |
| 41 | |
| 42 | *** Keywords *** |
| 43 | Read InputFile |
| 44 | ${serviceList}= utils.jsonToList ${PATHFILE} ServiceInfo |
| 45 | Set Suite Variable ${slist} ${serviceList} |
| 46 | ${putServiceList}= utils.jsonToList ${PATHFILE2} ServiceInfo |
| 47 | Set Suite Variable ${putList} ${putServiceList} |
| 48 | |
| 49 | Verify Service functionality |
| 50 | [Arguments] ${type} ${listIndex} |
| 51 | Run Keyword If "${type}" == "CREATE" Test Post Service API ${listIndex} |
| 52 | Run Keyword If "${type}" == "RETRIEVE" Test Get Service API ${listIndex} |
| 53 | Run Keyword If "${type}" == "PUT" Test Edit Service API ${listIndex} |
| 54 | Run Keyword If "${type}" == "DELETE" Test Delete Service API ${listIndex} |
| 55 | |
| 56 | Test Post Service API |
| 57 | [Arguments] ${listIndex} |
| 58 | ${serviceList} = Get Variable Value ${slist} |
| 59 | ${serviceDict}= utils.listToDict ${serviceList} ${listIndex} |
| 60 | ${api_result}= restApi.ApiPost CH_CORE_SERVICES ${serviceDict} |
| 61 | Should Be True ${api_result} |
| 62 | |
| 63 | Test Get Service API |
| 64 | [Arguments] ${listIndex} |
| 65 | ${json_result}= restApi.ApiGet CH_CORE_SERVICES |
| 66 | ${json_result_list}= Get From Dictionary ${json_result} items |
| 67 | Log ${json_result_list} |
| 68 | Log ${json_result} |
| 69 | ${serviceList}= Get Variable Value ${slist} |
| 70 | ${serviceDict}= utils.listToDict ${serviceList} ${listIndex} |
| 71 | ${name}= utils.getFieldValueFromDict ${serviceDict} name |
| 72 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} name ${name} |
| 73 | ${test_result}= utils.compare_dict ${serviceDict} ${getJsonDict} |
| 74 | Should Be True ${test_result} |
| 75 | |
| 76 | Test Edit Service API |
| 77 | [Arguments] ${listIndex} |
| 78 | ${get_result}= restApi.ApiGet CH_CORE_SERVICES |
| 79 | ${get_result_list}= Get From Dictionary ${get_result} items |
| 80 | ${putServiceList}= Get Variable Value ${putList} |
| 81 | ${putServiceDict}= utils.listToDict ${putServiceList} ${listIndex} |
| 82 | ${name}= utils.getFieldValueFromDict ${putServiceDict} name |
| 83 | ${serviceDict}= utils.getDictFromListofDict ${get_result_list} name ${name} |
| 84 | ${serviceID}= utils.getFieldValueFromDict ${serviceDict} id |
| 85 | ${api_result}= restApi.ApiChameleonPut CH_CORE_SERVICES ${putServiceDict} ${serviceID} |
| 86 | Should Be True ${api_result} |
| 87 | ${getResultAfterPut}= restApi.ApiChameleonGet CH_CORE_SERVICES ${serviceID} |
| 88 | ${test_result}= utils.compare_dict ${putServiceDict} ${getResultAfterPut} |
| 89 | Should Be True ${test_result} |
| 90 | |
| 91 | Test Delete Service API |
| 92 | [Arguments] ${listIndex} |
| 93 | ${json_result}= restApi.ApiGet CH_CORE_SERVICES |
| 94 | ${json_result_list}= Get From Dictionary ${json_result} items |
| 95 | ${serviceList}= Get Variable Value ${slist} |
| 96 | ${serviceDict}= utils.listToDict ${serviceList} ${listIndex} |
| 97 | ${name}= utils.getFieldValueFromDict ${serviceDict} name |
| 98 | Log ${name} |
| 99 | ${serviceDict}= utils.getDictFromListofDict ${json_result_list} name ${name} |
| 100 | Log ${serviceDict} |
| 101 | ${serviceId}= utils.getFieldValueFromDict ${serviceDict} id |
| 102 | Log ${serviceId} |
| 103 | ${test_result}= restApi.ApiChameleonDelete CH_CORE_SERVICES ${serviceId} |
| 104 | Should Be True ${test_result} |