-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestDataTable-API_requests.robot
355 lines (311 loc) · 12.4 KB
/
TestDataTable-API_requests.robot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
*** Settings ***
Resource environment.robot
Library Collections
Library JsonValidator
Library RequestsLibrary
Library OperatingSystem
Library String
Suite Setup Connect to TDT
Default Tags API RequestsLibrary
*** Test cases ***
Create Blank Table
[Tags] Create Table Negative Case
${resp}= PUT On Session TDT / expected_status=406
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 406
Should Be Equal "${resp.json()['message']}" "table name cannot be blank"
Create Table regression 1
[Tags] Create Table
${resp}= PUT On Session TDT /regression+1 expected_status=201
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 201
Should Be Equal "${resp.json()['message']}" "table regression 1 created"
Show Tables
[Tags] Table
${resp}= GET On Session TDT /tables
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
Table regression 1 exists
[Tags] Table
${resp}= GET On Session TDT /tables
Log ${resp}
log ${resp.json()}
log ${resp.content}
Should Be Equal As Strings ${resp.status_code} 200
${text}= Convert To String ${resp.content}
${tbl_id}= Select elements ${text} .table:contains("regression 1")~.tbl_id
${tbl_name}= Select elements ${text} .table:contains("regression 1")~.table
Should Be Equal "${tbl_name[0]}" "regression 1"
Create Table regression 1 again
[Tags] Create Table Negative Case
${resp}= PUT On Session TDT /regression+1
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
Should Be Equal "${resp.json()['message']}" "table regression 1 exists"
${resp}= GET On Session TDT /tables
Should Be Equal As Strings ${resp.status_code} 200
${text}= Convert To String ${resp.content}
${tbl_name}= Select elements ${text} .table:contains("regression 1")~.table
Should Be Equal "${tbl_name[0]}" "regression 1"
Create Blank Column
[Tags] Create Column Negative Case
${resp}= PUT On Session TDT /regression+1/ expected_status=406
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 406
Should Be Equal "${resp.json()['message']}" "column name cannot be blank"
Create Column Col_A
[Tags] Create Column
${resp}= PUT On Session TDT /regression+1/Col_A expected_status=201
Log ${resp}
log ${resp.json()}
# Expect Response { "status": "200" } merge=true
Should Be Equal As Strings ${resp.status_code} 201
Should Be Equal "${resp.json()['message']}" "column Col_A created"
Create Column Col_A again
[Tags] Create Column Negative Case
${resp}= PUT On Session TDT /regression+1/Col_A
Log ${resp}
log ${resp.json()}
# Expect Response { "status": "200" } merge=true
Should Be Equal As Strings ${resp.status_code} 200
Should Be Equal "${resp.json()['message']}" "column Col_A exists"
Get value from empty column
[Tags] Column Negative Case
${resp}= GET On Session TDT /regression 1/Col_A
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
${checkval1}= Set Variable ${resp.json()['Col_A']}
Should Be Equal As Strings ${checkval1} None
Create Column Col_B and Col_C
[Tags] Create Column
${resp}= PUT On Session TDT /regression+1/Col_B expected_status=201
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 201
${resp}= PUT On Session TDT /regression+1/Col_C expected_status=201
Log ${resp}
Should Be Equal As Strings ${resp.status_code} 201
Post row of data
[Tags] Create Values
${resp}= POST On Session TDT /regression+1/row {"Col_A":"Value A","Col_B":"Value B","Col_C":"Value C"} expected_status=201
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 201
${resp}= POST On Session TDT /regression+1/row {"Col_A":"Value X", "Col_B":"Value Y", "Col_C":"Value Z"} expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
${resp}= POST On Session TDT /regression+1/row {"Col_A":"Value D", "Col_B":"Value E", "Col_C":"Value F"} expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
${resp}= POST On Session TDT /regression+1/row {"Col_A":"Value G", "Col_B":"Value H", "Col_C":"Value I"} expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
${resp}= POST On Session TDT /regression+1/row {"Col_A":"Value J", "Col_B":"Value K", "Col_C":"Value L"} expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
Get all values for Column Col_A
[Tags] Values
${resp}= GET On Session TDT /regression+1/Col_A/all
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
Get Table regression 1 columns
[Tags] Table
${resp}= GET On Session TDT /regression+1/columns
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
Should Be Equal As Strings ${resp.json()['regression 1'][0]['count']} 5
Get Table regression 1 row
[Tags] Values
${resp}= GET On Session TDT /regression+1/row
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
Should Be Equal As Strings ${resp.json()['regression 1']['Col_C']} Value C
# return data row to table
${json_string}= evaluate json.dumps(${resp.json()['regression 1']}) json
${resp}= POST On Session TDT /regression+1/row ${json_string}
Should Be Equal As Strings ${resp.status_code} 201
Get Table regression 1 row 2
[Documentation] Get the third row of data (0,1,2)
[Tags] Values
${resp}= GET On Session TDT /regression+1/2
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
Should Be Equal As Strings ${resp.json()['regression 1']['Col_C']} Value I
# return data row to table
${json_string}= evaluate json.dumps(${resp.json()['regression 1']}) json
${resp}= POST On Session TDT /regression+1/row ${json_string} expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
Get Table regression 1 row 100
[Documentation] Get the 100th row of data
... as there are less than 10 rows, this should return 404 not found
[Tags] Values
${resp}= GET On Session TDT /regression+1/99 expected_status=404
Log ${resp}
Should Be Equal As Strings ${resp.status_code} 404
# DELETE /<table name>/<column name>
Delete Column Col_C
[Tags] Delete Column
${resp}= DELETE On Session TDT /regression+1/Col_C
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
# GET /<table name>/<column name>
Get Column Col_A
[Tags] Column
${resp}= GET On Session TDT /regression 1/Col_A
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
${checkval1}= Set Variable ${resp.json()['Col_A']}
${resp}= GET On Session TDT /regression 1/Col_A
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
${checkval2}= Set Variable ${resp.json()['Col_A']}
Should Not Be Equal ${checkval1} ${checkval2}
# put the values back
${resp}= PUT On Session TDT /regression 1/Col_A/${checkval2} expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
${resp}= PUT On Session TDT /regression 1/Col_A/${checkval1} expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
# PUT /<table name>/<column name>/<value>
Add value to Column Col_A
[Tags] Create Values
${resp}= PUT On Session TDT /regression 1/Col_A/Value 1 expected_status=201
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 201
Add more values to Column Col_A
[Tags] Create Values
${resp}= PUT On Session TDT /regression+1/Col_A/Value+2 expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
${resp}= PUT On Session TDT /regression+1/Col_A/Value+3 expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
${resp}= PUT On Session TDT /regression+1/Col_A/Value+4 expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
${resp}= PUT On Session TDT /regression+1/Col_A/Value+5 expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
${resp}= PUT On Session TDT /regression+1/Col_A/Value+6 expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
Delete Value 4 from Column Col_A
[Tags] Delete Values
${resp}= DELETE On Session TDT /regression 1/Col_A/Value 4
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
Get Table regression 1
[Tags] Table
${resp}= GET On Session TDT /regression+1
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
Replace value by current value
[Tags] Create Values
${resp}= PUT On Session TDT /regression+1/Col_A/Value X/New Value X
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
# GET /<table name>/<column name>/all
Get all values for Column Col_A for Value Id's
[Tags] Values
${resp}= GET On Session TDT /regression+1/Col_A/all
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
log ${resp.json()["Col_A"]}
log ${resp.json()["Col_A"][-1]}
log ${resp.json()["Col_A"][-1]["val_id"]}
# ${value_id}= Set Variable ${resp.json()["Col_A"][0]["val_id"]}
Set Global Variable ${value_id} ${resp.json()["Col_A"][-1]["val_id"]}
Replace value by id
[Tags] Create Values
${resp}= PUT On Session TDT /regression+1/Col_A/${value_id}/New Value
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
# GET /<table name>/<column name>/<id>
Get value by id from Column Col_A
[Tags] Values
${resp}= GET On Session TDT /regression+1/Col_A/${value_id}
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
Should Be Equal As Strings ${resp.json()["Col_A"]} New Value
Table doesn't exist
[Tags] Table Negative Case
${resp}= GET On Session TDT /regression 1998 expected_status=404
Log ${resp}
# log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 404
Table doesn't exist - columns
[Tags] Table Negative Case
${resp}= GET On Session TDT /regression 1999/columns expected_status=404
Log ${resp}
# log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 404
Column doesn't exist
[Tags] Column Negative Case
${resp}= GET On Session TDT /regression 1/joe citizen 2019 expected_status=404
Log ${resp}
# log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 404
Value Id doesn't exist
[Tags] Values Negative Case
# ${badval}= Evaluate ${value_id} * 2
${badval}= Set Variable 5c1d0000920000000000000000000000
${resp}= GET On Session TDT /regression+1/Col_A/${badval} expected_status=404
Log ${resp}
# log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 404
Delete Table regression 1
[Tags] Table Delete
${resp}= DELETE On Session TDT /regression+1
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
Table regression 1 removed
[Tags] Table Delete
${resp}= GET On Session TDT /tables
Log ${resp}
Should Be Equal As Strings ${resp.status_code} 200
# Missing $.tables[?(@.table=="regression 1")]
${text}= Convert To String ${resp.content}
${tbl_name}= Select elements ${text} .table:contains("regression 1")~.table
# Element should not exist ${text} .tables[?(@.table=="regression 1")]
Element should not exist ${text} .table:contains("regression 1")
Add value to create column and table
[Tags] Create Table Column Values
${resp}= PUT On Session TDT /Regression+Create/Col+Create/Value+Create expected_status=201
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 201
Log "Cleanup table Regression Create"
${resp}= DELETE On Session TDT /Regression+Create
Log ${resp}
log ${resp.json()}
Should Be Equal As Strings ${resp.status_code} 200
Create Demo Data
[Tags] Create Values
${resp}= PUT On Session TDT /Demo/Demo+1/data+value+1 expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
${resp}= PUT On Session TDT /Demo/Demo+1/data+value+2 expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
${resp}= PUT On Session TDT /Demo/Demo+1/data+value+3 expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
${resp}= PUT On Session TDT /Demo/Demo+2/data+value+21 expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
${resp}= PUT On Session TDT /Demo/Demo+2/data+value+22 expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
${resp}= PUT On Session TDT /Demo/Demo+2/data+value+23 expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
${resp}= PUT On Session TDT /Demo 2/Demo 3/data value 1 expected_status=201
Should Be Equal As Strings ${resp.status_code} 201
*** Keywords ***
Connect to TDT
Create Session TDT http://${TDT_Host}