blob: 2efcd989d5f87534432237d7ce449e114dbbf637 [file] [log] [blame]
Suchitra Vemurif7410a92017-05-16 17:04:05 -07001*** Settings ***
2Documentation Test suite for Sanity Test of Instance API
3Suite Setup Read InputFile
4Test Template Verify Instance API functionality
5Library Collections
6Library String
7Library OperatingSystem
8Library XML
9Library RequestsLibrary
10Library ../Framework/utils/utils.py
11Library ../Framework/restApi.py
12
13*** Variables ***
Suchitra Vemurif7410a92017-05-16 17:04:05 -070014${PATHFILE} ${CURDIR}/data/Ch_SanityInstance.json
15
16*** Test Cases *** TYPE LISTINDEX
17Test Add Instance-1
18 CREATE 0
19
20Test Get Instance-1
21 RETRIEVE 0
22
23Test Delete Instance-1
24 DELETE 0
25
26Test Add Instance-2
27 CREATE 1
28
29Test Get Instance-2
30 RETRIEVE 1
31
32Test Delete Instance-2
33 DELETE 1
34
35*** Keywords ***
36Read InputFile
37 ${instanceList} = utils.jsonToList ${PATHFILE} InstanceInfo
38 Set Suite Variable ${iList} ${instanceList}
39
40Verify Instance API functionality
41 [Arguments] ${type} ${listIndex}
42 Run Keyword If "${type}" == "CREATE" Test Post Instances ${listIndex}
43 Run Keyword If "${type}" == "RETRIEVE" Test Get Instances ${listIndex}
44 Run Keyword If "${type}" == "DELETE" Test Delete Instances ${listIndex}
45
46Test Post Instances
47 [Arguments] ${listIndex}
48 ${instanceList} = Get Variable Value ${iList}
49 ${instanceDict}= utils.listToDict ${instanceList} ${listIndex}
50 ${api_result}= restApi.ApiPost CH_CORE_INSTANCES ${instanceDict}
51 Should Be True ${api_result}
52
53Test Get Instances
54 [Arguments] ${listIndex}
55 ${json_result}= restApi.ApiGet CH_CORE_INSTANCES
56 Log ${json_result}
57 ${json_result_list}= Get From Dictionary ${json_result} items
58 Log ${json_result_list}
59 ${instanceList}= Get Variable Value ${iList}
60 ${inputDict}= utils.listToDict ${instanceList} ${listIndex}
61 ${instanceName}= utils.getFieldValueFromDict ${inputDict} name
62 ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} name ${instanceName}
63 ${test_result}= utils.compare_dict ${inputDict} ${getJsonDict}
64 Should Be True ${json_result}
65
66Test Delete Instances
67 [Arguments] ${listIndex}
68 ${json_getresult}= restApi.ApiGet CH_CORE_INSTANCES
69 ${json_getresult_list}= Get From Dictionary ${json_getresult} items
70 ${instanceList}= Get Variable Value ${iList}
71 ${instanceDict}= utils.listToDict ${iList} ${listIndex}
72 ${instanceName}= utils.getFieldValueFromDict ${instanceDict} name
73 Log ${instanceName}
74 ${getInstanceDict}= utils.getDictFromListofDict ${json_getresult_list} name ${instanceName}
75 Log ${getInstanceDict}
76 ${instanceID}= utils.getFieldValueFromDict ${getInstanceDict} id
77 Log ${instanceID}
78 ${test_result}= restApi.ApiChameleonDelete CH_CORE_INSTANCES ${instanceID}
79 Should be True ${test_result}