blob: b0141b0fe7a39ca134ef349bcc57c4a65f07a84d [file] [log] [blame]
You Wangf462ee92016-12-16 13:11:43 -08001*** Settings ***
2Documentation Test suite for Deployment verification
3Suite Setup Read InputFile
4Test Template Verify Deployment 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/Deployment.json
17${PATHFILE2} ${CURDIR}/data/putDeployment.json
18
19*** Test Cases *** TYPE LISTINDEX
20Test Post Deployment-1 CREATE 0
21
22Test Get Deployment-1 RETRIEVE 0
23
24#Test Edit Deployment-1 PUT 0
25
26Test Delete Deployment-1 DELETE 0
27
28Test Post Deployment-2 CREATE 1
29
30Test Get Deployment-2 RETRIEVE 1
31
32#Test Edit Deployment-2 PUT 1
33
34Test Delete Deployment-2 DELETE 1
35
36*** Keywords ***
37Read InputFile
38 ${deploymentList}= utils.jsonToList ${PATHFILE} DeploymentInfo
39 Set Suite Variable ${dlist} ${deploymentList}
40 ${putDeploymentList}= utils.jsonToList ${PATHFILE2} DeploymentInfo
41 Set Suite Variable ${putList} ${putDeploymentList}
42
43Verify Deployment functionality
44 [Arguments] ${type} ${listIndex}
45 Run Keyword If "${type}" == "CREATE" Test Post Deployment API ${listIndex}
46 Run Keyword If "${type}" == "RETRIEVE" Test Get Deployment API ${listIndex}
47 Run Keyword If "${type}" == "PUT" Test Edit Deployment API ${listIndex}
48 Run Keyword If "${type}" == "DELETE" Test Delete Deployment API ${listIndex}
49
50Test Post Deployment API
51 [Arguments] ${listIndex}
52 ${deploymentList} = Get Variable Value ${dlist}
53 ${deploymentDict}= utils.listToDict ${deploymentList} ${listIndex}
54 ${api_result}= restApi.ApiPost CORE_DEPLOYMENTS ${deploymentDict}
55 Should Be True ${api_result}
56
57Test Get Deployment API
58 [Arguments] ${listIndex}
59 ${json_result}= restApi.ApiGet CORE_DEPLOYMENTS
60 Log ${json_result}
61 ${deploymentList}= Get Variable Value ${dlist}
62 ${deploymentDict}= utils.listToDict ${deploymentList} ${listIndex}
63 ${name}= utils.getFieldValueFromDict ${deploymentDict} name
64 ${getJsonDict}= utils.getDictFromListOfDict ${json_result} name ${name}
65 ${test_result}= utils.compare_dict ${deploymentDict} ${getJsonDict}
66 Should Be True ${test_result}
67
68Test Edit Deployment API
69 [Arguments] ${listIndex}
70 ${get_result}= restApi.ApiGet CORE_DEPLOYMENTS
71 ${putDeploymentList}= Get Variable Value ${putList}
72 ${putDeploymentDict}= utils.listToDict ${putDeploymentList} ${listIndex}
73 ${name}= utils.getFieldValueFromDict ${putDeploymentDict} name
74 ${deploymentDict}= utils.getDictFromListofDict ${get_result} name ${name}
75 ${deploymentID}= utils.getFieldValueFromDict ${deploymentDict} id
76 ${api_result}= restApi.ApiPut CORE_DEPLOYMENTS ${putDeploymentDict} ${deploymentID}
77 Should Be True ${api_result}
78 ${getResultAfterPut}= restApi.ApiGet CORE_DEPLOYMENTS ${deploymentID}
79 ${test_result}= utils.compare_dict ${putDeploymentDict} ${getResultAfterPut}
80 Should Be True ${test_result}
81
82Test Delete Deployment API
83 [Arguments] ${listIndex}
84 ${json_result}= restApi.ApiGet CORE_DEPLOYMENTS
85 ${deploymentList}= Get Variable Value ${dlist}
86 ${deploymentDict}= utils.listToDict ${deploymentList} ${listIndex}
87 ${name}= utils.getFieldValueFromDict ${deploymentDict} name
88 Log ${name}
89 ${deploymentDict}= utils.getDictFromListofDict ${json_result} name ${name}
90 Log ${deploymentDict}
91 ${deploymentId}= utils.getFieldValueFromDict ${deploymentDict} id
92 Log ${deploymentId}
93 ${test_result}= restApi.ApiDelete CORE_DEPLOYMENTS ${deploymentId}
94 Should Be True ${test_result}