Suchitra Vemuri | da8492a | 2017-06-15 14:47:24 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test suite for Instance creation for multiple subscribers with same "s_tag" - Chameleon APIs |
| 3 | Suite Setup Read InputFile |
| 4 | Test Template Verify Single Instance 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_Subscriber.json |
| 17 | ${PATHFILE2} ${CURDIR}/data/Ch_MultiInstance_VoltTenant.json |
| 18 | |
| 19 | *** Test Cases *** TYPE LISTINDEX |
| 20 | Test Create Subscriber-1 |
| 21 | SUBSCRIBER_CREATE 0 |
| 22 | |
| 23 | Test Create Subscriber-2 |
| 24 | SUBSCRIBER_CREATE 1 |
| 25 | |
| 26 | Test Create Subscriber-3 |
| 27 | SUBSCRIBER_CREATE 2 |
| 28 | |
| 29 | Test Create Tenant-1 |
| 30 | TENANT_CREATE 0 |
| 31 | |
| 32 | Test Create Tenant-2 |
| 33 | TENANT_CREATE 1 |
| 34 | |
| 35 | Test Create Tenant-3 |
| 36 | TENANT_CREATE 2 |
| 37 | |
| 38 | Test Instance creation validation |
| 39 | INSTANCE_VALIDATE 0 |
| 40 | |
| 41 | *** Keywords *** |
| 42 | Read InputFile |
| 43 | ${subscriberList} = utils.jsonToList ${PATHFILE} SubscriberInfo |
| 44 | Set Suite Variable ${slist} ${subscriberList} |
| 45 | ${voltList}= utils.jsonToList ${PATHFILE2} voltSubscriberInfo |
| 46 | Set Suite Variable ${vlist} ${voltList} |
| 47 | @{instanceList}= Create List |
| 48 | Set Suite Variable @{instanceList} |
| 49 | |
| 50 | Verify Single Instance functionality |
| 51 | [Arguments] ${type} ${listIndex} |
| 52 | Run Keyword If "${type}" == "SUBSCRIBER_CREATE" Test Post Subscriber Create ${listIndex} |
| 53 | Run Keyword If "${type}" == "TENANT_CREATE" Test Post volt Tenant Create ${listIndex} |
| 54 | Run Keyword If "${type}" == "INSTANCE_VALIDATE" Test Instance Validation ${listIndex} |
| 55 | |
| 56 | Test Post Subscriber Create |
| 57 | [Arguments] ${listIndex} |
| 58 | ${subscriberList} = Get Variable Value ${slist} |
| 59 | ${subscriberDict}= utils.listToDict ${subscriberList} ${listIndex} |
| 60 | ${api_result}= restApi.ApiPost VOLT_SUBSCRIBER ${subscriberDict} |
| 61 | ${instanceList} Create List |
| 62 | |
| 63 | Test Post volt Tenant Create |
| 64 | [Arguments] ${listIndex} |
| 65 | ${voltTenantList} = Get Variable Value ${vlist} |
| 66 | ${voltTenantDict}= utils.listToDict ${voltTenantList} ${listIndex} |
| 67 | ${voltDict}= Get From Dictionary ${voltTenantDict} voltTenant |
| 68 | ${service_specific_id}= Get From Dictionary ${voltTenantDict} service_specific_id |
| 69 | ${get_result}= restApi.ApiGet VOLT_SUBSCRIBER |
| 70 | ${get_result_list}= Get From Dictionary ${get_result} items |
| 71 | ${subscriberDict}= utils.getDictFromListofDict ${get_result_list} service_specific_id ${service_specific_id} |
| 72 | ${subscriberID}= utils.getFieldValueFromDict ${subscriberDict} id |
| 73 | ${updatedVoltDict}= utils.setFieldValueInDict ${voltDict} subscriber_root_id ${subscriberID} |
| 74 | ${api_result}= restApi.ApiPost VOLT_TENANT ${updatedVoltDict} |
| 75 | Should Be True ${api_result} |
| 76 | # Verifying Get operation after POST |
| 77 | Sleep 20 |
| 78 | ${getVolt_result}= restApi.ApiGet VOLT_TENANT |
| 79 | Log ${getVolt_result} |
| 80 | ${getVolt_result_list}= utils.getFieldValueFromDict ${getVolt_result} items |
| 81 | Log ${getVolt_result_list} |
| 82 | ${getJsonDict}= utils.getDictFromListOfDict ${getVolt_result_list} subscriber_root_id ${subscriberID} |
| 83 | Log ${getJsonDict} |
| 84 | ${test_result}= utils.compare_dict ${voltDict} ${getJsonDict} |
| 85 | Should Be True ${test_result} |
| 86 | # Validation of Instances |
| 87 | Log ${instanceList} |
| 88 | Log ${getJsonDict} |
| 89 | ${VSGTenantList}= Get From Dictionary ${getJsonDict} subscribed_tenants_ids |
| 90 | Log ${VSGTenantList} |
| 91 | ${VSGTenant}= Get From List ${VSGTenantList} 0 |
| 92 | ${getVSG_result}= restApi.ApiChameleonGet VSG_TENANT ${VSGTenant} |
| 93 | ${instance_id}= Get From Dictionary ${getVSG_result} instance_id |
| 94 | Append To List ${instanceList} ${instance_id} |
| 95 | Log ${instanceList} |
| 96 | ${get_CoreInstanceresult}= restApi.ApiChameleonGet CH_CORE_INSTANCES ${instance_id} |
| 97 | Should Be True ${get_CoreInstanceresult} |
| 98 | |
| 99 | Test Instance Validation |
| 100 | [Arguments] ${listIndex} |
| 101 | ${get_result}= restApi.ApiGet VSG_TENANT |
| 102 | Should Be True ${get_result} |
| 103 | ${instanceFinalList}= Remove Duplicates ${instanceList} |
| 104 | Log ${instanceFinalList} |
| 105 | ${instanceCount}= Get Length ${instanceFinalList} |
| 106 | Log ${instanceCount} |
| 107 | Should Be True ${instanceCount} == 3 |