blob: 0bf27f843ad6b794e0a17aa56423e6d1d770cf06 [file] [log] [blame]
You Wang6f0fd1f2016-12-21 14:55:56 -08001*** Settings ***
You Wang123d6942017-03-01 12:33:02 -08002Documentation Test suite for Sanity Test of Node API
You Wang6f0fd1f2016-12-21 14:55:56 -08003Suite Setup Read InputFile
4Test Template Verify Node 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/sanityNode.json
17
18*** Test Cases *** TYPE LISTINDEX
19Test Post Node-1 CREATE 0
20
21#Test Get Node-1 RETRIEVE 0
22
23Test Delete Node-1 DELETE 0
24
25Test Post Node-2 CREATE 1
26
27#Test Get Node-2 RETRIEVE 1
28
29Test Delete Node-2 DELETE 1
30
31*** Keywords ***
32Read InputFile
33 ${nodeList}= utils.jsonToList ${PATHFILE} NodeInfo
34 Set Suite Variable ${nlist} ${nodeList}
35
36Verify Node functionality
37 [Arguments] ${type} ${listIndex}
38 Run Keyword If "${type}" == "CREATE" Test Post Node API ${listIndex}
39 Run Keyword If "${type}" == "RETRIEVE" Test Get Node API ${listIndex}
40 Run Keyword If "${type}" == "DELETE" Test Delete Node API ${listIndex}
41
42Test Post Node API
43 [Arguments] ${listIndex}
44 ${nodeList}= Get Variable Value ${nlist}
45 ${nodeDict}= utils.listToDict ${nodeList} ${listIndex}
46 ${api_result}= restApi.ApiPost CORE_SANITY_NODES ${nodeDict}
47 Should Be True ${api_result}
48
49Test Get Node API
50 [Arguments] ${listIndex}
51 ${json_result}= restApi.ApiGet CORE_NODES
52 Log ${json_result}
53 ${nodeList}= Get Variable Value ${nlist}
54 ${nodeDict}= utils.listToDict ${nodeList} ${listIndex}
55 ${name}= utils.getFieldValueFromDict ${nodeDict} name
56 ${getJsonDict}= utils.getDictFromListOfDict ${json_result} name ${name}
57 ${test_result}= utils.compare_dict ${nodeDict} ${getJsonDict}
58 Should Be True ${test_result}
59
60Test Delete Node API
61 [Arguments] ${listIndex}
62 ${json_result}= restApi.ApiGet CORE_NODES
63 ${nodeList}= Get Variable Value ${nlist}
64 ${nodeDict}= utils.listToDict ${nodeList} ${listIndex}
65 ${name}= utils.getFieldValueFromDict ${nodeDict} name
66 Log ${name}
67 ${nodeDict}= utils.getDictFromListofDict ${json_result} name ${name}
68 Log ${nodeDict}
69 ${nodeId}= utils.getFieldValueFromDict ${nodeDict} id
70 Log ${nodeId}
71 ${test_result}= restApi.ApiDelete CORE_NODES ${nodeId}
72 Should Be True ${test_result}