blob: 01a972d08e12a4928079ebcc01392ea2567d5714 [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 ***
14${USER} admin
15${PASSWORD} admin
16${PATHFILE} ${CURDIR}/data/Ch_SanityInstance.json
17
18*** Test Cases *** TYPE LISTINDEX
19Test Add Instance-1
20 CREATE 0
21
22Test Get Instance-1
23 RETRIEVE 0
24
25Test Delete Instance-1
26 DELETE 0
27
28Test Add Instance-2
29 CREATE 1
30
31Test Get Instance-2
32 RETRIEVE 1
33
34Test Delete Instance-2
35 DELETE 1
36
37*** Keywords ***
38Read InputFile
39 ${instanceList} = utils.jsonToList ${PATHFILE} InstanceInfo
40 Set Suite Variable ${iList} ${instanceList}
41
42Verify Instance API functionality
43 [Arguments] ${type} ${listIndex}
44 Run Keyword If "${type}" == "CREATE" Test Post Instances ${listIndex}
45 Run Keyword If "${type}" == "RETRIEVE" Test Get Instances ${listIndex}
46 Run Keyword If "${type}" == "DELETE" Test Delete Instances ${listIndex}
47
48Test Post Instances
49 [Arguments] ${listIndex}
50 ${instanceList} = Get Variable Value ${iList}
51 ${instanceDict}= utils.listToDict ${instanceList} ${listIndex}
52 ${api_result}= restApi.ApiPost CH_CORE_INSTANCES ${instanceDict}
53 Should Be True ${api_result}
54
55Test Get Instances
56 [Arguments] ${listIndex}
57 ${json_result}= restApi.ApiGet CH_CORE_INSTANCES
58 Log ${json_result}
59 ${json_result_list}= Get From Dictionary ${json_result} items
60 Log ${json_result_list}
61 ${instanceList}= Get Variable Value ${iList}
62 ${inputDict}= utils.listToDict ${instanceList} ${listIndex}
63 ${instanceName}= utils.getFieldValueFromDict ${inputDict} name
64 ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} name ${instanceName}
65 ${test_result}= utils.compare_dict ${inputDict} ${getJsonDict}
66 Should Be True ${json_result}
67
68Test Delete Instances
69 [Arguments] ${listIndex}
70 ${json_getresult}= restApi.ApiGet CH_CORE_INSTANCES
71 ${json_getresult_list}= Get From Dictionary ${json_getresult} items
72 ${instanceList}= Get Variable Value ${iList}
73 ${instanceDict}= utils.listToDict ${iList} ${listIndex}
74 ${instanceName}= utils.getFieldValueFromDict ${instanceDict} name
75 Log ${instanceName}
76 ${getInstanceDict}= utils.getDictFromListofDict ${json_getresult_list} name ${instanceName}
77 Log ${getInstanceDict}
78 ${instanceID}= utils.getFieldValueFromDict ${getInstanceDict} id
79 Log ${instanceID}
80 ${test_result}= restApi.ApiChameleonDelete CH_CORE_INSTANCES ${instanceID}
81 Should be True ${test_result}