blob: 4299da19f348d54320de5871a40a1557fa4de3aa [file] [log] [blame]
Suchitra Vemurif7410a92017-05-16 17:04:05 -07001*** Settings ***
2Documentation Test suite for Slice API verification
3Suite Setup Read InputFile
4Test Template Verify Slice API functionality
5Library Collections
6Library String
7Library OperatingSystem
8Library XML
9Library RequestsLibrary
10Library ../Framework/utils/utils.py
11Library ../Framework/restApi.py
12Variables ../Properties/RestApiProperties.py
13
14*** Variables ***
Suchitra Vemurif7410a92017-05-16 17:04:05 -070015${PATHFILE} ${CURDIR}/data/Ch_Slice.json
16${IP} ${SERVER_IP}
17${PORT} ${SERVER_PORT}
18
19*** Test Cases *** TYPE LISTINDEX
20Test Add Slice-1 CREATE 0
21
22Test Get Slice-1 RETRIEVE 0
23
24Test Delete Slice-1
25 DELETE 0
26
27*** Keywords ***
28Read InputFile
29 ${sliceList} = utils.jsonToList ${PATHFILE} SliceInfo
30 Set Suite Variable ${sList} ${sliceList}
31
32Verify Slice API functionality
33 [Arguments] ${type} ${listIndex}
34 Run Keyword If "${type}" == "CREATE" Test Post Slice API ${listIndex}
35 Run Keyword If "${type}" == "RETRIEVE" Test Get Slice API ${listIndex}
36 Run Keyword If "${type}" == "DELETE" Test Delete Slice API ${listIndex}
37
38Test Post Slice API
39 [Arguments] ${listIndex}
40 ${sliceList} = Get Variable Value ${sList}
41 ${sliceDict}= utils.listToDict ${sliceList} ${listIndex}
42 ${api_result}= restApi.ApiPost CH_CORE_SLICES ${sliceDict}
43 Should Be True ${api_result}
44
45Test Get Slice API
46 [Arguments] ${listIndex}
47 ${json_result}= restApi.ApiGet CH_CORE_SLICES
48 ${json_result_list}= Get From Dictionary ${json_result} items
49 Log ${json_result_list}
50 ${sliceList}= Get Variable Value ${sList}
51 ${sliceDict}= utils.listToDict ${sliceList} ${listIndex}
52 ${sliceName}= Get From Dictionary ${sliceDict} name
53 ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} name ${sliceName}
54 ${test_result}= utils.compare_dict ${sliceDict} ${getJsonDict}
55 Should Be True ${json_result}
56
57Test Delete Slice API
58 [Arguments] ${listIndex}
59 ${json_getresult}= restApi.ApiGet CH_CORE_SLICES
60 ${json_getresult_list}= Get From Dictionary ${json_getresult} items
61 ${sliceList}= Get Variable Value ${sList}
62 ${sliceDict}= utils.listToDict ${sList} ${listIndex}
63 ${sliceName}= utils.getFieldValueFromDict ${sliceDict} name
64 Log ${sliceName}
65 ${getSliceDict}= utils.getDictFromListofDict ${json_getresult_list} name ${sliceName}
66 Log ${getSliceDict}
67 ${sliceID}= utils.getFieldValueFromDict ${getSliceDict} id
68 Log ${sliceID}
69 ${test_result}= restApi.ApiChameleonDelete CH_CORE_SLICES ${sliceID}
70 Should be True ${test_result}