blob: fda6537f0eef65571bed55c8115a870e3fc90e31 [file] [log] [blame]
You Wang123d6942017-03-01 12:33:02 -08001*** 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
12| Variables | ../Properties/RestApiProperties.py
13
14*** Variables ***
15${USER} admin
16${PASSWORD} admin
17${PATHFILE} ${CURDIR}/data/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} /api/core/sitedeployments/1/
39 Set Suite Variable ${siteDeployment} ${siteDeployment}
40
41Verify Node API functionality
42 [Arguments] ${type} ${listIndex}
43 Run Keyword If "${type}" == "CREATE" Test Post Node API ${listIndex}
44 Run Keyword If "${type}" == "RETRIEVE" Test Get Node API ${listIndex}
45 Run Keyword If "${type}" == "DELETE" Test Delete Node API ${listIndex}
46
47Test Post Node API
48 [Arguments] ${listIndex}
49 ${nodeList}= Get Variable Value ${nlist}
50 ${nodeDict}= utils.listToDict ${nodeList} ${listIndex}
51 ${siteDeployment}= Get Variable Value ${siteDeployment}
52 ${nodeDict}= utils.setFieldValueInDict ${nodeDict} site_deployment ${siteDeployment}
53 ${api_result}= restApi.ApiPost CORE_NODES ${nodeDict}
54 Should Be True ${api_result}
55
56Test Get Node API
57 [Arguments] ${listIndex}
58 ${json_result}= restApi.ApiGet CORE_NODES
59 Log ${json_result}
60 ${nodeList}= Get Variable Value ${nlist}
61 ${nodeDict}= utils.listToDict ${nodeList} ${listIndex}
62 ${siteDeployment}= Get Variable Value ${siteDeployment}
63 ${nodeDict}= utils.setFieldValueInDict ${nodeDict} site_deployment ${siteDeployment}
64 ${name}= utils.getFieldValueFromDict ${nodeDict} name
65 ${getJsonDict}= utils.getDictFromListOfDict ${json_result} name ${name}
66 ${test_result}= utils.compare_dict ${nodeDict} ${getJsonDict}
67 Should Be True ${test_result}
68
69Test Delete Node API
70 [Arguments] ${listIndex}
71 ${json_result}= restApi.ApiGet CORE_NODES
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} name ${name}
77 Log ${nodeDict}
78 ${nodeId}= utils.getFieldValueFromDict ${nodeDict} id
79 Log ${nodeId}
80 ${test_result}= restApi.ApiDelete CORE_NODES ${nodeId}
81 Should Be True ${test_result}