blob: 09e482938923d04693ee820b6626b329ccc4c17f [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
Zack Williams821c5022020-01-15 15:11:46 -070010Library CORDRobot
11Library ImportResource resources=CORDRobot
Suchitra Vemurif7410a92017-05-16 17:04:05 -070012Variables ../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
Zack Williams821c5022020-01-15 15:11:46 -070034 ${nodeList}= CORDRobot.jsonToList ${PATHFILE} NodeInfo
Suchitra Vemurif7410a92017-05-16 17:04:05 -070035 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}
Zack Williams821c5022020-01-15 15:11:46 -070049 ${nodeDict}= CORDRobot.listToDict ${nodeList} ${listIndex}
50 ${api_result}= CORDRobot.ApiPost CH_CORE_NODES ${nodeDict}
Suchitra Vemurif7410a92017-05-16 17:04:05 -070051 Should Be True ${api_result}
52
53Test Get Node API
54 [Arguments] ${listIndex}
Zack Williams821c5022020-01-15 15:11:46 -070055 ${json_result}= CORDRobot.ApiGet CH_CORE_NODES
Suchitra Vemurif7410a92017-05-16 17:04:05 -070056 ${json_result_list}= Get From Dictionary ${json_result} items
57 Log ${json_result_list}
58 ${nodeList}= Get Variable Value ${nlist}
Zack Williams821c5022020-01-15 15:11:46 -070059 ${nodeDict}= CORDRobot.listToDict ${nodeList} ${listIndex}
60 ${name}= CORDRobot.getFieldValueFromDict ${nodeDict} name
Suchitra Vemurif7410a92017-05-16 17:04:05 -070061 Log ${name}
Zack Williams821c5022020-01-15 15:11:46 -070062 ${getJsonDict}= CORDRobot.getDictFromListOfDict ${json_result_list} name ${name}
63 ${test_result}= CORDRobot.compare_dict ${nodeDict} ${getJsonDict}
Suchitra Vemurif7410a92017-05-16 17:04:05 -070064 Should Be True ${test_result}
65
66Test Delete Node API
67 [Arguments] ${listIndex}
Zack Williams821c5022020-01-15 15:11:46 -070068 ${json_result}= CORDRobot.ApiGet CH_CORE_NODES
Suchitra Vemurif7410a92017-05-16 17:04:05 -070069 ${json_result_list}= Get From Dictionary ${json_result} items
70 ${nodeList}= Get Variable Value ${nlist}
Zack Williams821c5022020-01-15 15:11:46 -070071 ${nodeDict}= CORDRobot.listToDict ${nodeList} ${listIndex}
72 ${name}= CORDRobot.getFieldValueFromDict ${nodeDict} name
Suchitra Vemurif7410a92017-05-16 17:04:05 -070073 Log ${name}
Zack Williams821c5022020-01-15 15:11:46 -070074 ${nodeDict}= CORDRobot.getDictFromListofDict ${json_result_list} name ${name}
Suchitra Vemurif7410a92017-05-16 17:04:05 -070075 Log ${nodeDict}
Zack Williams821c5022020-01-15 15:11:46 -070076 ${nodeId}= CORDRobot.getFieldValueFromDict ${nodeDict} id
Suchitra Vemurif7410a92017-05-16 17:04:05 -070077 Log ${nodeId}
Zack Williams821c5022020-01-15 15:11:46 -070078 ${test_result}= CORDRobot.ApiChameleonDelete CH_CORE_NODES ${nodeId}
Suchitra Vemurif7410a92017-05-16 17:04:05 -070079 Should Be True ${test_result}