blob: 6e1a74b4ab461c2c1198b4f89c22d23770d769f0 [file] [log] [blame]
Suchitra.Vemuri75dffd42016-12-20 15:35:25 -08001*** Settings ***
2Documentation Test suite for Sanity Test of Slice API
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
12
13*** Variables ***
14${USER} admin
15${PASSWORD} admin
16${PATHFILE} ${CURDIR}/data/Sanity_slice.json
17
18*** Test Cases *** TYPE LISTINDEX
19Test Add Slice-1 CREATE 0
20
21Test Get Slice-1 RETRIEVE 0
22
23Test Delete Slice-1
24 DELETE 0
25
26Test Add Slice-2 CREATE 1
27
28Test Get Slice-2 RETRIEVE 1
29
30Test Delete Slice-2
31 DELETE 1
32
33*** Keywords ***
34Read InputFile
35 ${sliceList} = utils.jsonToList ${PATHFILE} sliceInfo
36 Set Suite Variable ${sList} ${sliceList}
37
38Verify Slice API functionality
39 [Arguments] ${type} ${listIndex}
40 Run Keyword If "${type}" == "CREATE" Test Post Instances ${listIndex}
41 Run Keyword If "${type}" == "RETRIEVE" Test Get Instances ${listIndex}
42 Run Keyword If "${type}" == "DELETE" Test Delete Instances ${listIndex}
43
44Test Post Instances
45 [Arguments] ${listIndex}
46 ${sliceList} = Get Variable Value ${sList}
47 ${sliceDict}= utils.listToDict ${sliceList} ${listIndex}
48 ${api_result}= restApi.ApiPost CORE_SANITY_SLICES ${sliceDict}
49 Should Be True ${api_result}
50
51Test Get Instances
52 [Arguments] ${listIndex}
53 ${json_result}= restApi.ApiGet CORE_SLICES
54 Log ${json_result}
55 ${sliceList}= Get Variable Value ${sList}
56 ${inputDict}= utils.listToDict ${sliceList} ${listIndex}
57 ${ID}= utils.getFieldValueFromDict ${inputDict} id
58 ${getJsonDict}= utils.getDictFromListOfDict ${json_result} id ${ID}
59 ${test_result}= utils.compare_dict ${inputDict} ${getJsonDict}
60 Should Be True ${json_result}
61
62Test Delete Instances
63 [Arguments] ${listIndex}
64 ${json_getresult}= restApi.ApiGet CORE_SLICES
65 ${sliceList}= Get Variable Value ${sList}
66 ${sliceDict}= utils.listToDict ${sList} ${listIndex}
67 ${sliceName}= utils.getFieldValueFromDict ${sliceDict} name
68 Log ${sliceName}
69 ${getSliceDict}= utils.getDictFromListofDict ${json_getresult} name ${sliceName}
70 Log ${getSliceDict}
71 ${sliceID}= utils.getFieldValueFromDict ${getSliceDict} id
72 Log ${sliceID}
73 ${test_result}= restApi.ApiDelete CORE_SLICES ${sliceID}
74 Should be True ${test_result}