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