blob: 108e6c913b69b03c83485f006c093cfa1bd566af [file] [log] [blame]
Suchitra Vemurif7410a92017-05-16 17:04:05 -07001*** Settings ***
2Documentation Test suite for Node API verification
3Suite Setup Read InputFile
4Test Template Verify Node 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_Node.json
16${IP} ${SERVER_IP}
17${PORT} ${SERVER_PORT}
18
19*** Test Cases *** TYPE LISTINDEX
20Test Post Node-1 CREATE 0
21
22Test Get Node-1 RETRIEVE 0
23
24Test Delete Node-1 DELETE 0
25
26Test Post Node-2 CREATE 1
27
28Test Get Node-2 RETRIEVE 1
29
30Test Delete Node-2 DELETE 1
31
32*** Keywords ***
33Read InputFile
34 ${nodeList}= utils.jsonToList ${PATHFILE} NodeInfo
35 Set Suite Variable ${nlist} ${nodeList}
36 ${siteDeployment}= Catenate SEPARATOR= http:// ${IP} : ${PORT}
37 ... /api/core/sitedeployments/1/
38 Set Suite Variable ${siteDeployment} ${siteDeployment}
39
40Verify Node API functionality
41 [Arguments] ${type} ${listIndex}
42 Run Keyword If "${type}" == "CREATE" Test Post Node API ${listIndex}
43 Run Keyword If "${type}" == "RETRIEVE" Test Get Node API ${listIndex}
44 Run Keyword If "${type}" == "DELETE" Test Delete Node API ${listIndex}
45
46Test Post Node API
47 [Arguments] ${listIndex}
48 ${nodeList}= Get Variable Value ${nlist}
49 ${nodeDict}= utils.listToDict ${nodeList} ${listIndex}
50 ${api_result}= restApi.ApiPost CH_CORE_NODES ${nodeDict}
51 Should Be True ${api_result}
52
53Test Get Node API
54 [Arguments] ${listIndex}
55 ${json_result}= restApi.ApiGet CH_CORE_NODES
56 ${json_result_list}= Get From Dictionary ${json_result} items
57 Log ${json_result_list}
58 ${nodeList}= Get Variable Value ${nlist}
59 ${nodeDict}= utils.listToDict ${nodeList} ${listIndex}
60 ${name}= utils.getFieldValueFromDict ${nodeDict} name
61 Log ${name}
62 ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} name ${name}
63 ${test_result}= utils.compare_dict ${nodeDict} ${getJsonDict}
64 Should Be True ${test_result}
65
66Test Delete Node API
67 [Arguments] ${listIndex}
68 ${json_result}= restApi.ApiGet CH_CORE_NODES
69 ${json_result_list}= Get From Dictionary ${json_result} items
70 ${nodeList}= Get Variable Value ${nlist}
71 ${nodeDict}= utils.listToDict ${nodeList} ${listIndex}
72 ${name}= utils.getFieldValueFromDict ${nodeDict} name
73 Log ${name}
74 ${nodeDict}= utils.getDictFromListofDict ${json_result_list} name ${name}
75 Log ${nodeDict}
76 ${nodeId}= utils.getFieldValueFromDict ${nodeDict} id
77 Log ${nodeId}
78 ${test_result}= restApi.ApiChameleonDelete CH_CORE_NODES ${nodeId}
79 Should Be True ${test_result}