blob: d3b1f1cb76148a50fc61dcbda36f31c5f1d9d0f1 [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
27#Test Delete VOLTDevice-1
28# DELETE 0
29Test Create VOLTDevice-2
30 CREATE 1
31Test Get VOLTDevice-2
32 RETRIEVE 1
33Test Create PONPort-2
34 PONCREATE 1
35Test Get PONPort-2
36 PONRETRIEVE 1
37#Test Delete VOLTDevice-2
38# DELETE 1
39Test Create VOLTDevice-3
40 CREATE 2
41Test Get VOLTDevice-3
42 RETRIEVE 2
43Test Create PONPort-3
44 CREATE 2
45Test Get PONPort-3
46 RETRIEVE 2
47#Test Delete VOLTDevice-3
48# DELETE 2
49
50
51*** Keywords ***
52Read InputFile
53 ${voltDeviceList}= utils.jsonToList ${PATHFILE} VOLTDeviceInfo
54 Set Suite Variable ${dlist} ${voltDeviceList}
55 Set Global Variable ${VOLTDevice_Id} ${EMPTY}
56 ${PONPortList}= utils.jsonToList ${PATHFILE1} PONPortInfo
57 Set Suite Variable ${plist} ${PONPortList}
58 Set Suite Variable ${PONPort_Id} ${EMPTY}
59
60Verify VOLTDevice functionality
61 [Arguments] ${type} ${listIndex}
62 Run Keyword If "${type}" == "CREATE" Test Post VOLT Device API ${listIndex}
63 Run Keyword If "${type}" == "RETRIEVE" Test Get VOLT Device API ${listIndex}
64 Run Keyword If "${type}" == "DELETE" Test Delete VOLT Device API ${listIndex}
65 Run Keyword If "${type}" == "PONCREATE" Test Post PONPort API ${listIndex}
66 Run Keyword If "${type}" == "PONRETRIEVE" Test Get PONPort API ${listIndex}
67
68Test Post VOLT Device API
69 [Arguments] ${listIndex}
70 ${voltDeviceList} = Get Variable Value ${dlist}
71 ${voltDeviceDict}= utils.listToDict ${voltDeviceList} ${listIndex}
72 ${api_getResult}= restApi.ApiGet VOLT_SERVICE
73 ${voltServiceList}= Get From Dictionary ${api_getResult} items
74 ${voltServiceDict}= utils.getDictFromListOfDict ${voltServiceList} leaf_model_name VOLTService
75 ${VOLTService_Id}= Get From Dictionary ${voltServiceDict} id
76 ${voltDeviceDict}= utils.setFieldValueInDict ${voltDeviceDict} volt_service_id ${VOLTService_Id}
77 Log ${voltDeviceDict}
78 ${api_result_status} ${api_result_json}= restApi.ApiPostReturnJson VOLT_DEVICE ${voltDeviceDict}
79 Should Be True ${api_result_status}
80 ${VOLTDevice_Id}= Get From Dictionary ${api_result_json} id
81 Set Global Variable ${VOLTDevice_Id}
82
83Test Get VOLT Device API
84 [Arguments] ${listIndex}
85 Log ${VOLTDevice_Id}
86 ${json_result}= restApi.ApiChameleonGet VOLT_DEVICE ${VOLTDevice_Id}
87 Log ${json_result}
88 ${voltDeviceList} = Get Variable Value ${dlist}
89 ${voltDeviceDict}= utils.listToDict ${voltDeviceList} ${listIndex}
90 Log ${voltDeviceDict}
91 ${test_result}= utils.compare_dict ${voltDeviceDict} ${json_result}
92 Should Be True ${test_result}
93
94Test Post PONPort API
95 [Arguments] ${listIndex}
96 ${PONPortList} = Get Variable Value ${plist}
97 ${PONPortDict}= utils.listToDict ${PONPortList} ${listIndex}
98 ${PONPortDict}= utils.setFieldValueInDict ${PONPortDict} olt_device_id ${VOLTDevice_Id}
99 ${api_result_status} ${api_result_json}= restApi.ApiPostReturnJson PON_PORT ${PONPortDict}
100 Should Be True ${api_result_status}
101 ${PONPort_Id}= Get From Dictionary ${api_result_json} id
102 Set Global Variable ${PONPort_Id}
103
104Test Get PONPort API
105 [Arguments] ${listIndex}
106 Log ${PONPort_Id}
107 ${json_result}= restApi.ApiChameleonGet PON_PORT ${PONPort_Id}
108 Log ${json_result}
109 ${PONPortList} = Get Variable Value ${plist}
110 ${PONPortDict}= utils.listToDict ${PONPortList} ${listIndex}
111 Log ${PONPortDict}
112 ${test_result}= utils.compare_dict ${PONPortDict} ${json_result}
113 Should Be True ${test_result}
114
115Test Delete VOLT Device API
116 [Arguments] ${listIndex}
117 ${test_result}= restApi.ApiChameleonDelete VOLT_DEVICE ${VOLTDevice_Id}
118 Should Be True ${test_result}