You Wang | 0869a32 | 2016-12-05 16:55:51 -0800 | [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 |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame^] | 10 | Library CORDRobot |
| 11 | Library ImportResource resources=CORDRobot |
You Wang | 0869a32 | 2016-12-05 16:55:51 -0800 | [diff] [blame] | 12 | |
| 13 | *** Variables *** |
| 14 | ${USER} admin |
| 15 | ${PASSWORD} admin |
| 16 | ${PATHFILE} ${CURDIR}/data/Service.json |
| 17 | ${PATHFILE2} ${CURDIR}/data/putService.json |
| 18 | |
| 19 | *** Test Cases *** TYPE LISTINDEX |
| 20 | Test Post Service-1 CREATE 0 |
| 21 | |
| 22 | Test Get Service-1 RETRIEVE 0 |
| 23 | |
| 24 | Test Edit Service-1 PUT 0 |
| 25 | |
| 26 | Test Delete Service-1 DELETE 0 |
| 27 | |
| 28 | Test Post Service-2 CREATE 1 |
| 29 | |
| 30 | Test Get Service-2 RETRIEVE 1 |
| 31 | |
| 32 | Test Edit Service-2 PUT 1 |
| 33 | |
| 34 | Test Delete Service-2 DELETE 1 |
| 35 | |
| 36 | *** Keywords *** |
| 37 | Read InputFile |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame^] | 38 | ${serviceList}= CORDRobot.jsonToList ${PATHFILE} ServiceInfo |
You Wang | 0869a32 | 2016-12-05 16:55:51 -0800 | [diff] [blame] | 39 | Set Suite Variable ${slist} ${serviceList} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame^] | 40 | ${putServiceList}= CORDRobot.jsonToList ${PATHFILE2} ServiceInfo |
You Wang | 0869a32 | 2016-12-05 16:55:51 -0800 | [diff] [blame] | 41 | Set Suite Variable ${putList} ${putServiceList} |
| 42 | |
| 43 | Verify Service functionality |
| 44 | [Arguments] ${type} ${listIndex} |
| 45 | Run Keyword If "${type}" == "CREATE" Test Post Service API ${listIndex} |
| 46 | Run Keyword If "${type}" == "RETRIEVE" Test Get Service API ${listIndex} |
| 47 | Run Keyword If "${type}" == "PUT" Test Edit Service API ${listIndex} |
| 48 | Run Keyword If "${type}" == "DELETE" Test Delete Service API ${listIndex} |
| 49 | |
| 50 | Test Post Service API |
| 51 | [Arguments] ${listIndex} |
| 52 | ${serviceList} = Get Variable Value ${slist} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame^] | 53 | ${serviceDict}= CORDRobot.listToDict ${serviceList} ${listIndex} |
| 54 | ${api_result}= CORDRobot.ApiPost CORE_SERVICES ${serviceDict} |
You Wang | 0869a32 | 2016-12-05 16:55:51 -0800 | [diff] [blame] | 55 | Should Be True ${api_result} |
| 56 | |
| 57 | Test Get Service API |
| 58 | [Arguments] ${listIndex} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame^] | 59 | ${json_result}= CORDRobot.ApiGet CORE_SERVICES |
You Wang | 0869a32 | 2016-12-05 16:55:51 -0800 | [diff] [blame] | 60 | Log ${json_result} |
| 61 | ${serviceList}= Get Variable Value ${slist} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame^] | 62 | ${serviceDict}= CORDRobot.listToDict ${serviceList} ${listIndex} |
| 63 | ${name}= CORDRobot.getFieldValueFromDict ${serviceDict} name |
| 64 | ${getJsonDict}= CORDRobot.getDictFromListOfDict ${json_result} name ${name} |
| 65 | ${test_result}= CORDRobot.compare_dict ${serviceDict} ${getJsonDict} |
You Wang | 0869a32 | 2016-12-05 16:55:51 -0800 | [diff] [blame] | 66 | Should Be True ${test_result} |
| 67 | |
| 68 | Test Edit Service API |
| 69 | [Arguments] ${listIndex} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame^] | 70 | ${get_result}= CORDRobot.ApiGet CORE_SERVICES |
You Wang | 0869a32 | 2016-12-05 16:55:51 -0800 | [diff] [blame] | 71 | ${putServiceList}= Get Variable Value ${putList} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame^] | 72 | ${putServiceDict}= CORDRobot.listToDict ${putServiceList} ${listIndex} |
| 73 | ${name}= CORDRobot.getFieldValueFromDict ${putServiceDict} name |
| 74 | ${serviceDict}= CORDRobot.getDictFromListofDict ${get_result} name ${name} |
| 75 | ${serviceID}= CORDRobot.getFieldValueFromDict ${serviceDict} id |
| 76 | ${api_result}= CORDRobot.ApiPut CORE_SERVICES ${putServiceDict} ${serviceID} |
You Wang | 0869a32 | 2016-12-05 16:55:51 -0800 | [diff] [blame] | 77 | Should Be True ${api_result} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame^] | 78 | ${getResultAfterPut}= CORDRobot.ApiGet CORE_SERVICES ${serviceID} |
| 79 | ${test_result}= CORDRobot.compare_dict ${putServiceDict} ${getResultAfterPut} |
You Wang | 0869a32 | 2016-12-05 16:55:51 -0800 | [diff] [blame] | 80 | Should Be True ${test_result} |
| 81 | |
| 82 | Test Delete Service API |
| 83 | [Arguments] ${listIndex} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame^] | 84 | ${json_result}= CORDRobot.ApiGet CORE_SERVICES |
You Wang | 0869a32 | 2016-12-05 16:55:51 -0800 | [diff] [blame] | 85 | ${serviceList}= Get Variable Value ${slist} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame^] | 86 | ${serviceDict}= CORDRobot.listToDict ${serviceList} ${listIndex} |
| 87 | ${name}= CORDRobot.getFieldValueFromDict ${serviceDict} name |
You Wang | 0869a32 | 2016-12-05 16:55:51 -0800 | [diff] [blame] | 88 | Log ${name} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame^] | 89 | ${serviceDict}= CORDRobot.getDictFromListofDict ${json_result} name ${name} |
You Wang | 0869a32 | 2016-12-05 16:55:51 -0800 | [diff] [blame] | 90 | Log ${serviceDict} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame^] | 91 | ${serviceId}= CORDRobot.getFieldValueFromDict ${serviceDict} id |
You Wang | 0869a32 | 2016-12-05 16:55:51 -0800 | [diff] [blame] | 92 | Log ${serviceId} |
Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame^] | 93 | ${test_result}= CORDRobot.ApiDelete CORE_SERVICES ${serviceId} |
You Wang | 0869a32 | 2016-12-05 16:55:51 -0800 | [diff] [blame] | 94 | Should Be True ${test_result} |