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