blob: 9f06ad101feeff6ba637c9581d292b3ec8223449 [file] [log] [blame]
Suchitra Vemurif7410a92017-05-16 17:04:05 -07001*** Settings ***
2Documentation Test suite for Service verification
3Suite Setup Read InputFile
4Test Template Verify Service 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/Ch_Service.json
17${PATHFILE2} ${CURDIR}/data/Ch_putService.json
18
19*** Test Cases *** TYPE LISTINDEX
20Test Post Service-1
21 CREATE 0
22
23Test Get Service-1 RETRIEVE 0
24
25Test Edit Service-1
26 PUT 0
27
28Test Delete Service-1
29 DELETE 0
30
31Test Post Service-2
32 CREATE 1
33
34Test Get Service-2 RETRIEVE 1
35
36Test Edit Service-2
37 PUT 1
38
39Test Delete Service-2
40 DELETE 1
41
42*** Keywords ***
43Read InputFile
44 ${serviceList}= utils.jsonToList ${PATHFILE} ServiceInfo
45 Set Suite Variable ${slist} ${serviceList}
46 ${putServiceList}= utils.jsonToList ${PATHFILE2} ServiceInfo
47 Set Suite Variable ${putList} ${putServiceList}
48
49Verify Service functionality
50 [Arguments] ${type} ${listIndex}
51 Run Keyword If "${type}" == "CREATE" Test Post Service API ${listIndex}
52 Run Keyword If "${type}" == "RETRIEVE" Test Get Service API ${listIndex}
53 Run Keyword If "${type}" == "PUT" Test Edit Service API ${listIndex}
54 Run Keyword If "${type}" == "DELETE" Test Delete Service API ${listIndex}
55
56Test Post Service API
57 [Arguments] ${listIndex}
58 ${serviceList} = Get Variable Value ${slist}
59 ${serviceDict}= utils.listToDict ${serviceList} ${listIndex}
60 ${api_result}= restApi.ApiPost CH_CORE_SERVICES ${serviceDict}
61 Should Be True ${api_result}
62
63Test Get Service API
64 [Arguments] ${listIndex}
65 ${json_result}= restApi.ApiGet CH_CORE_SERVICES
66 ${json_result_list}= Get From Dictionary ${json_result} items
67 Log ${json_result_list}
68 Log ${json_result}
69 ${serviceList}= Get Variable Value ${slist}
70 ${serviceDict}= utils.listToDict ${serviceList} ${listIndex}
71 ${name}= utils.getFieldValueFromDict ${serviceDict} name
72 ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} name ${name}
73 ${test_result}= utils.compare_dict ${serviceDict} ${getJsonDict}
74 Should Be True ${test_result}
75
76Test Edit Service API
77 [Arguments] ${listIndex}
78 ${get_result}= restApi.ApiGet CH_CORE_SERVICES
79 ${get_result_list}= Get From Dictionary ${get_result} items
80 ${putServiceList}= Get Variable Value ${putList}
81 ${putServiceDict}= utils.listToDict ${putServiceList} ${listIndex}
82 ${name}= utils.getFieldValueFromDict ${putServiceDict} name
83 ${serviceDict}= utils.getDictFromListofDict ${get_result_list} name ${name}
84 ${serviceID}= utils.getFieldValueFromDict ${serviceDict} id
85 ${api_result}= restApi.ApiChameleonPut CH_CORE_SERVICES ${putServiceDict} ${serviceID}
86 Should Be True ${api_result}
87 ${getResultAfterPut}= restApi.ApiChameleonGet CH_CORE_SERVICES ${serviceID}
88 ${test_result}= utils.compare_dict ${putServiceDict} ${getResultAfterPut}
89 Should Be True ${test_result}
90
91Test Delete Service API
92 [Arguments] ${listIndex}
93 ${json_result}= restApi.ApiGet CH_CORE_SERVICES
94 ${json_result_list}= Get From Dictionary ${json_result} items
95 ${serviceList}= Get Variable Value ${slist}
96 ${serviceDict}= utils.listToDict ${serviceList} ${listIndex}
97 ${name}= utils.getFieldValueFromDict ${serviceDict} name
98 Log ${name}
99 ${serviceDict}= utils.getDictFromListofDict ${json_result_list} name ${name}
100 Log ${serviceDict}
101 ${serviceId}= utils.getFieldValueFromDict ${serviceDict} id
102 Log ${serviceId}
103 ${test_result}= restApi.ApiChameleonDelete CH_CORE_SERVICES ${serviceId}
104 Should Be True ${test_result}