Suchitra.Vemuri | 8be1880 | 2016-11-16 16:59:54 -0800 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test suite for Utility Synchronizer API |
| 3 | Suite Setup Read InputFile |
| 4 | Test Template Verify User 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/CoreUsers.json |
| 17 | |
| 18 | *** Test Cases *** TYPE LISTINDEX |
| 19 | Test Add User-1 CREATE 0 |
| 20 | |
| 21 | Test Get User-1 RETRIEVE 0 |
| 22 | |
| 23 | Test Delete User-1 DELETE 0 |
| 24 | |
| 25 | Test Add Synchronizer-2 |
| 26 | CREATE 1 |
| 27 | |
| 28 | Test Get Synchronizer-2 |
| 29 | RETRIEVE 1 |
| 30 | |
| 31 | Test Delete Synchronizer-2 |
| 32 | DELETE 1 |
| 33 | |
| 34 | Test Add Synchronizer-3 |
| 35 | CREATE 2 |
| 36 | |
| 37 | Test Get Synchronizer-3 |
| 38 | RETRIEVE 2 |
| 39 | |
| 40 | Test Delete Synchronizer-3 |
| 41 | DELETE 2 |
| 42 | |
| 43 | *** Keywords *** |
| 44 | Read InputFile |
| 45 | ${userList} = utils.jsonToList ${PATHFILE} UserInfo |
| 46 | Set Suite Variable ${uList} ${userList} |
| 47 | |
| 48 | Verify User functionality |
| 49 | [Arguments] ${type} ${listIndex} |
| 50 | Run Keyword If "${type}" == "CREATE" Test Post Users API ${listIndex} |
| 51 | Run Keyword If "${type}" == "RETRIEVE" Test Get Users API ${listIndex} |
| 52 | Run Keyword If "${type}" == "DELETE" Test Delete Users API ${listIndex} |
| 53 | |
| 54 | Test Post Users API |
| 55 | [Arguments] ${listIndex} |
| 56 | ${userList} = Get Variable Value ${uList} |
| 57 | ${userDict}= utils.listToDict ${userList} ${listIndex} |
| 58 | ${api_result}= restApi.ApiPost CORE_USERS ${userDict} |
| 59 | Should Be True ${api_result} |
| 60 | |
| 61 | Test Get Users API |
| 62 | [Arguments] ${listIndex} |
| 63 | ${json_result}= restApi.ApiGet CORE_USERS |
| 64 | Log ${json_result} |
| 65 | ${userList}= Get Variable Value ${uList} |
| 66 | ${inputDict}= utils.listToDict ${userList} ${listIndex} |
| 67 | ${email}= utils.getFieldValueFromDict ${inputDict} email |
| 68 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result} email ${email} |
| 69 | ${test_result}= utils.compare_dict ${inputDict} ${getJsonDict} |
| 70 | Should Be True ${json_result} |
| 71 | |
| 72 | Test Delete Users API |
| 73 | [Arguments] ${listIndex} |
| 74 | ${json_getresult}= restApi.ApiGet CORE_USERS |
| 75 | ${userList}= Get Variable Value ${uList} |
| 76 | ${userDict}= utils.listToDict ${uList} ${listIndex} |
| 77 | ${email}= utils.getFieldValueFromDict ${userDict} email |
| 78 | Log ${email} |
| 79 | ${getUserDict}= utils.getDictFromListofDict ${json_getresult} email ${email} |
| 80 | Log ${getUserDict} |
| 81 | ${userID}= utils.getFieldValueFromDict ${getUserDict} id |
| 82 | Log ${userID} |
| 83 | ${test_result}= restApi.ApiDelete CORE_USERS ${userID} |
| 84 | Should be True ${test_result} |