-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSWAPI.postman_collection.json
348 lines (348 loc) · 11.2 KB
/
SWAPI.postman_collection.json
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
{
"info": {
"_postman_id": "d524fa3a-a74c-4e4d-b02c-0dad3167ff83",
"name": "SWAPI",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "1. Get SWAPI Categories",
"event": [
{
"listen": "test",
"script": {
"id": "86fded3b-711d-4646-b41d-9ae4364c1ddb",
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"var response = JSON.parse(responseBody);",
"if (response !== null) {",
" tests[\"Category people exist\"] = response.people.indexOf('people');",
" tests[\"Category planets exist\"] = response.people.indexOf('planets');",
" tests[\"Category films exist\"] = response.people.indexOf('films');",
" tests[\"Category species exist\"] = response.people.indexOf('species');",
" tests[\"Category vehicles exist\"] = response.people.indexOf('vehicles');",
" tests[\"Category starships exist\"] = response.people.indexOf('starships');",
"}",
" else {",
"\ttests[\"There's no categories available\"] = false;",
"}",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"url": {
"raw": "{{BaseUrl}}/",
"host": [
"{{BaseUrl}}"
],
"path": [
""
]
}
},
"response": []
},
{
"name": "2. Get Obi-Wan Kenobi info profile",
"event": [
{
"listen": "test",
"script": {
"id": "fbade32c-7b54-4c20-a54f-2934555c6929",
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"var numberOfPeople = pm.globals.get(\"count\");",
"",
"var response = JSON.parse(responseBody);",
"",
"if (response !== null) {",
"",
" for (var i = 0; i < response.results.length; i++) {",
" if (response.results[i].name === \"Obi-Wan Kenobi\") {",
"",
" //ObiWan characteristics",
" var obiId = response.results[i].url.slice(28, 30);",
" console.log(\"Obi id\" + obiId);",
" tests[\"Obi-Wan people Id =\" + obiId] = response.results[i].url.indexOf(obiId);;",
" pm.globals.set(\"ObiId \", obiId);",
"",
" tests[\"Obi-Wan height = 182\"] = response.results[i].height === \"182\";",
" tests[\"Obi-Wan mass = 77\"] = response.results[i].mass === \"77\";",
" tests[\"Obi-Wan hair color = auburn, white\"] = response.results[i].hair_color === \"auburn, white\";",
" tests[\"Obi-Wan skin color = fair\"] = response.results[i].skin_color === \"fair\";",
" tests[\"Obi-Wan eye color = blue-gray\"] = response.results[i].eye_color === \"blue-gray\";",
" tests[\"Obi-Wan birth year = 57BBY\"] = response.results[i].birth_year === \"57BBY\";",
" tests[\"Obi-Wan gender = male\"] = response.results[i].gender === \"male\";",
"",
" //ObiWan home",
" var homeWorldId = response.results[i].homeworld.slice(30, 32);",
" console.log(\"Homeworld id \" + homeWorldId);",
" tests[\"Obi-Wan homeworld id =\" + homeWorldId] = response.results[i].homeworld.indexOf(homeWorldId);",
" pm.globals.set(\"homeWorldId\", homeWorldId);",
"",
" //ObiWan films",
" var filmsNumber = response.results[i].films.length;",
" tests[\"Obi-Wan number of films = \" + filmsNumber] = response.results[i].films.length;",
"",
" const filmsArray = [];",
" for (var j = 0; j < response.results[i].films.length; j++) {",
" var filmId = response.results[i].films[j].slice(27, 28);",
" console.log(filmId);",
" filmsArray.push(filmId);",
" }",
" console.log(\"Films array ids filled\" + filmsArray);",
" tests[\"Obi-Wan participate in films = \" + filmsArray] = filmsArray;",
"",
" //ObiWan vehicles",
" const vehiclesArray = [];",
" for (var k = 0; k < response.results[i].vehicles.length; k++) {",
" var vehiclesId = response.results[i].vehicles[k].slice(31, 33);",
" console.log(vehiclesId);",
" vehiclesArray.push(vehiclesId);",
" tests[\"Obi-Wan vehicle id =\" + vehiclesId] = response.results[i].vehicles;",
" pm.globals.set(\"vehicleId\", vehiclesId);",
" }",
"",
" //ObiWan starship",
" var starshipNumber = response.results[i].starships.length;",
" tests[\"Obi-Wan number of starship = \" + starshipNumber] = response.results[i].starships.length;",
"",
" const starshipsArray = [];",
" for (var l = 0; l < response.results[i].starships.length; l++) {",
" var starshipId = response.results[i].starships[l].slice(31, 33);",
" console.log(starshipId);",
" starshipsArray.push(starshipId);",
" }",
" console.log(\"Starship array ids filled\" + starshipsArray);",
" tests[\"Obi-Wan have starships = \" + starshipsArray] = starshipsArray;",
" }",
" }",
"",
"}",
"else {",
" tests[\"There's no categories available\"] = false;",
"}",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"url": {
"raw": "{{BaseUrl}}/people",
"host": [
"{{BaseUrl}}"
],
"path": [
"people"
]
}
},
"response": []
},
{
"name": "3. Get Obi-Wan Kenobi vehicle info",
"event": [
{
"listen": "test",
"script": {
"id": "33b0dec0-7c17-4ede-a052-3c0fb1b7663a",
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"var obiId = pm.globals.get(\"ObiId\");",
"var obiFilms = pm.globals.get(\"filmsArray\");",
"",
"var response = JSON.parse(responseBody);",
"",
"if (response !== null) {",
"",
" if (response.pilots.indexOf(obiId) && response.films.indexOf(obiFilms) ){",
"",
" tests[\"Vehicle name = Tribubble bongo\"] = response.name === \"Tribubble bongo\";",
" tests[\"Manufacturer = Otoh Gunga Bongameken Cooperative\"] = response.manufacturer === \"Otoh Gunga Bongameken Cooperative\";",
" tests[\"Crew = 1\"] = response.crew === \"1\";",
" tests[\"Passengers = 2\"] = response.passengers === \"2\";",
" tests[\"cargo_capacity = 1600\"] = response.cargo_capacity === \"1600\";",
" tests[\"Vehicle_class = submarine\"] = response.vehicle_class === \"submarine\";",
"",
" }",
"}",
"else {",
" tests[\"There's no vehicle available\"] = false;",
"}",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"url": {
"raw": "{{BaseUrl}}/vehicles/{{vehicleId}}",
"host": [
"{{BaseUrl}}"
],
"path": [
"vehicles",
"{{vehicleId}}"
]
}
},
"response": []
},
{
"name": "4. Get Obi-Wan Kenobi openings films and director of each movie",
"event": [
{
"listen": "test",
"script": {
"id": "dbe8dcc1-da68-4dee-bd14-57af1e71e1a5",
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"var obiId = pm.globals.get(\"obiId\");",
"var obiFilms = pm.globals.get(\"filmsArray\");",
"",
"console.log(obiId);",
"var response = JSON.parse(responseBody);",
"",
"",
"if (response !== null) {",
" for (var i = 0; i < response.results.length; i++) {",
" for (var j = 0; j < response.results[i].characters.length; j++) {",
" if (response.results[i].characters.indexOf(\"people/\" + obiId + \"/\")) {",
"",
" tests[\"Title =\" + response.results[i].title] = true",
" tests[\"Director =\" + response.results[i].director] = true;",
" tests[\"Opening crawl =\" + response.results[i].opening_crawl] = true;",
" }",
" }",
" }",
"}",
"else {",
" tests[\"There's no films available\"] = false;",
"}",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"url": {
"raw": "{{BaseUrl}}/films/",
"host": [
"{{BaseUrl}}"
],
"path": [
"films",
""
]
}
},
"response": []
},
{
"name": "5. Get Obi-Wan Kenobi planet info",
"event": [
{
"listen": "test",
"script": {
"id": "be931322-9513-4e4e-bc7f-8f4ac03448f0",
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"var homeWorldId = pm.globals.get(\"homeWorldId\");",
"",
"var response = JSON.parse(responseBody);",
"",
"",
"if (response !== null) {",
"",
" if (response.url.indexOf(\"planets/\" + homeWorldId + \"/\")) {",
" tests[\"Planet name = \" + response.name] =response.name=== \"Stewjon\";",
" tests[\"climate = \" + response.climate] = response.climate===\"temperate\";",
" tests[\"diameter = \" + response.diameter] = response.diameter === \"0\";",
" tests[\"gravity = \" + response.gravity] = response.gravity===\"1 standard\";",
" tests[\"terrain = \" + response.terrain] = response.terrain===\"grass\";",
" tests[\"surface water = \" + response.surface_water] = response.surface_water===\"unknown\";",
" }",
"}",
"else {",
" tests[\"There's no planet available\"] = false;",
"}",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"url": {
"raw": "{{BaseUrl}}/planets/{{homeWorldId}}",
"host": [
"{{BaseUrl}}"
],
"path": [
"planets",
"{{homeWorldId}}"
]
}
},
"response": []
}
],
"protocolProfileBehavior": {}
}