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