blob: 1bbf672f0c676615f05c1f08f5bc80c852a91143 [file] [log] [blame]
Suchitra Vemuri7dbf03c2018-04-25 23:06:23 -07001*** Settings ***
2Documentation Test suite for VOLTDevice
3Suite Setup Read InputFile
4Test Template Verify VOLTDevice functionality
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/VOLTDevice.json
15${PATHFILE1} ${CURDIR}/data/PONPort.json
16
17*** Test Cases *** TYPE LISTINDEX
18Test Create VOLTDevice-1
19 CREATE 0
20Test Get VOLTDevice-1
21 RETRIEVE 0
22Test Create PONPort-1
23 PONCREATE 0
24
25Test Get PONPort-1
26 PONRETRIEVE 0
Suchitra Vemuri7dbf03c2018-04-25 23:06:23 -070027Test Create VOLTDevice-2
28 CREATE 1
29Test Get VOLTDevice-2
30 RETRIEVE 1
31Test Create PONPort-2
32 PONCREATE 1
33Test Get PONPort-2
34 PONRETRIEVE 1
Suchitra Vemuri7dbf03c2018-04-25 23:06:23 -070035Test Create VOLTDevice-3
36 CREATE 2
37Test Get VOLTDevice-3
38 RETRIEVE 2
39Test Create PONPort-3
Suchitra Vemurib3478552018-04-27 18:05:27 -070040 PONCREATE 2
Suchitra Vemuri7dbf03c2018-04-25 23:06:23 -070041Test Get PONPort-3
Suchitra Vemurib3478552018-04-27 18:05:27 -070042 PONRETRIEVE 2
Suchitra Vemuri7dbf03c2018-04-25 23:06:23 -070043
44
45*** Keywords ***
46Read InputFile
47 ${voltDeviceList}= utils.jsonToList ${PATHFILE} VOLTDeviceInfo
48 Set Suite Variable ${dlist} ${voltDeviceList}
49 Set Global Variable ${VOLTDevice_Id} ${EMPTY}
50 ${PONPortList}= utils.jsonToList ${PATHFILE1} PONPortInfo
51 Set Suite Variable ${plist} ${PONPortList}
52 Set Suite Variable ${PONPort_Id} ${EMPTY}
53
54Verify VOLTDevice functionality
55 [Arguments] ${type} ${listIndex}
56 Run Keyword If "${type}" == "CREATE" Test Post VOLT Device API ${listIndex}
57 Run Keyword If "${type}" == "RETRIEVE" Test Get VOLT Device API ${listIndex}
58 Run Keyword If "${type}" == "DELETE" Test Delete VOLT Device API ${listIndex}
59 Run Keyword If "${type}" == "PONCREATE" Test Post PONPort API ${listIndex}
60 Run Keyword If "${type}" == "PONRETRIEVE" Test Get PONPort API ${listIndex}
61
62Test Post VOLT Device API
63 [Arguments] ${listIndex}
64 ${voltDeviceList} = Get Variable Value ${dlist}
65 ${voltDeviceDict}= utils.listToDict ${voltDeviceList} ${listIndex}
66 ${api_getResult}= restApi.ApiGet VOLT_SERVICE
67 ${voltServiceList}= Get From Dictionary ${api_getResult} items
68 ${voltServiceDict}= utils.getDictFromListOfDict ${voltServiceList} leaf_model_name VOLTService
69 ${VOLTService_Id}= Get From Dictionary ${voltServiceDict} id
70 ${voltDeviceDict}= utils.setFieldValueInDict ${voltDeviceDict} volt_service_id ${VOLTService_Id}
71 Log ${voltDeviceDict}
72 ${api_result_status} ${api_result_json}= restApi.ApiPostReturnJson VOLT_DEVICE ${voltDeviceDict}
73 Should Be True ${api_result_status}
74 ${VOLTDevice_Id}= Get From Dictionary ${api_result_json} id
75 Set Global Variable ${VOLTDevice_Id}
76
77Test Get VOLT Device API
78 [Arguments] ${listIndex}
79 Log ${VOLTDevice_Id}
80 ${json_result}= restApi.ApiChameleonGet VOLT_DEVICE ${VOLTDevice_Id}
81 Log ${json_result}
82 ${voltDeviceList} = Get Variable Value ${dlist}
83 ${voltDeviceDict}= utils.listToDict ${voltDeviceList} ${listIndex}
84 Log ${voltDeviceDict}
85 ${test_result}= utils.compare_dict ${voltDeviceDict} ${json_result}
86 Should Be True ${test_result}
87
88Test Post PONPort API
89 [Arguments] ${listIndex}
90 ${PONPortList} = Get Variable Value ${plist}
91 ${PONPortDict}= utils.listToDict ${PONPortList} ${listIndex}
92 ${PONPortDict}= utils.setFieldValueInDict ${PONPortDict} olt_device_id ${VOLTDevice_Id}
93 ${api_result_status} ${api_result_json}= restApi.ApiPostReturnJson PON_PORT ${PONPortDict}
94 Should Be True ${api_result_status}
95 ${PONPort_Id}= Get From Dictionary ${api_result_json} id
96 Set Global Variable ${PONPort_Id}
97
98Test Get PONPort API
99 [Arguments] ${listIndex}
100 Log ${PONPort_Id}
101 ${json_result}= restApi.ApiChameleonGet PON_PORT ${PONPort_Id}
102 Log ${json_result}
103 ${PONPortList} = Get Variable Value ${plist}
104 ${PONPortDict}= utils.listToDict ${PONPortList} ${listIndex}
105 Log ${PONPortDict}
106 ${test_result}= utils.compare_dict ${PONPortDict} ${json_result}
107 Should Be True ${test_result}
108
109Test Delete VOLT Device API
110 [Arguments] ${listIndex}
111 ${test_result}= restApi.ApiChameleonDelete VOLT_DEVICE ${VOLTDevice_Id}
112 Should Be True ${test_result}