blob: 86faa32d52392d3678018a67d87da60d8294104c [file] [log] [blame]
Suchitra Vemuri0f3dd092018-07-10 17:24:56 -07001*** Settings ***
2Documentation Test suite for configuring OLT device using REST APIs
3Suite Setup Read InputFile
4Test Template Configuring Real OLT device
5Library Collections
6Library String
7Library OperatingSystem
8Library XML
9Library RequestsLibrary
10Library ../Framework/utils/utils.py
11Library ../Framework/restApi.py
12
13*** Variables ***
14${PATHFILE} ${CURDIR}/data/RealOLTDevice.json
15
16*** Test Cases *** TYPE LISTINDEX
17Test Create VOLTDevice-1
18 CREATE 0
19Test Get VOLTDevice-1
20 RETRIEVE 0
21
22*** Keywords ***
23Read InputFile
24 ${voltDeviceList}= utils.jsonToList ${PATHFILE} VOLTDeviceInfo
25 Set Suite Variable ${dlist} ${voltDeviceList}
26 Set Global Variable ${VOLTDevice_Id} ${EMPTY}
27
28Configuring Real OLT device
29 [Arguments] ${type} ${listIndex}
30 Run Keyword If "${type}" == "CREATE" Test Post VOLT Device API ${listIndex}
31 Run Keyword If "${type}" == "RETRIEVE" Test Get VOLT Device API ${listIndex}
32
33Test Post VOLT Device API
34 [Arguments] ${listIndex}
35 ${voltDeviceList} = Get Variable Value ${dlist}
36 ${voltDeviceDict}= utils.listToDict ${voltDeviceList} ${listIndex}
37 ${api_getResult}= restApi.ApiGet VOLT_SERVICE
38 ${voltServiceList}= Get From Dictionary ${api_getResult} items
39 ${voltServiceDict}= utils.getDictFromListOfDict ${voltServiceList} leaf_model_name VOLTService
40 ${VOLTService_Id}= Get From Dictionary ${voltServiceDict} id
41 ${voltDeviceDict}= utils.setFieldValueInDict ${voltDeviceDict} volt_service_id ${VOLTService_Id}
42 Log ${voltDeviceDict}
43 ${api_result_status} ${api_result_json}= restApi.ApiPostReturnJson VOLT_DEVICE ${voltDeviceDict}
44 Should Be True ${api_result_status}
45 ${VOLTDevice_Id}= Get From Dictionary ${api_result_json} id
46 Set Global Variable ${VOLTDevice_Id}
47
48Test Get VOLT Device API
49 [Arguments] ${listIndex}
50 Log ${VOLTDevice_Id}
51 ${json_result}= restApi.ApiChameleonGet VOLT_DEVICE ${VOLTDevice_Id}
52 Log ${json_result}
53 ${voltDeviceList} = Get Variable Value ${dlist}
54 ${voltDeviceDict}= utils.listToDict ${voltDeviceList} ${listIndex}
55 Log ${voltDeviceDict}
56 ${test_result}= utils.compare_dict ${voltDeviceDict} ${json_result}
57 Should Be True ${test_result}