|
215 | 215 |
|
216 | 216 | # STEP_START get_bikes
|
217 | 217 | res2 = r.json().get("bikes:inventory", "$.inventory.*")
|
218 |
| -print( |
219 |
| - res2 |
220 |
| -) |
| 218 | +print(res2) |
221 | 219 | # >>> [[{'id': 'bike:1', 'model': 'Phoebe',
|
222 | 220 | # >>> 'description': 'This is a mid-travel trail slayer...
|
223 | 221 | # STEP_END
|
|
262 | 260 | "bikes:inventory",
|
263 | 261 | "$..mountain_bikes[?(@.price < 3000 && @.specs.weight < 10)]",
|
264 | 262 | )
|
265 |
| -print( |
266 |
| - res8 |
267 |
| -) # >>> [{'id': 'bike:2', 'model': 'Quaoar', |
| 263 | +print(res8) |
| 264 | +# >>> [{'id': 'bike:2', 'model': 'Quaoar', |
268 | 265 | # 'description': "Redesigned for the 2020 model year...
|
269 | 266 | # STEP_END
|
270 | 267 |
|
271 | 268 | # REMOVE_START
|
272 |
| -assert res8 == [{ |
273 |
| - 'id': 'bike:2', 'model': 'Quaoar', |
274 |
| - 'description': "Redesigned for the 2020 model year, this bike impressed " |
275 |
| - "our testers and is the best all-around trail bike we've ever tested. " |
276 |
| - "The Shimano gear system effectively does away with an external cassette, " |
277 |
| - "so is super low maintenance in terms of wear and tear. All in all it's " |
278 |
| - "an impressive package for the price, making it very competitive.", |
279 |
| - 'price': 2072, 'specs': {'material': 'aluminium', 'weight': 7.9}, |
280 |
| - 'colors': ['black', 'white']}] |
| 269 | +assert res8 == [ |
| 270 | + { |
| 271 | + 'id': 'bike:2', |
| 272 | + 'model': 'Quaoar', |
| 273 | + 'description': "Redesigned for the 2020 model year, this bike impressed " |
| 274 | + "our testers and is the best all-around trail bike we've ever tested. " |
| 275 | + "The Shimano gear system effectively does away with an external cassette, " |
| 276 | + "so is super low maintenance in terms of wear and tear. All in all it's " |
| 277 | + "an impressive package for the price, making it very competitive.", |
| 278 | + 'price': 2072, |
| 279 | + 'specs': {'material': 'aluminium', 'weight': 7.9}, |
| 280 | + 'colors': ['black', 'white'] |
| 281 | + } |
| 282 | +] |
281 | 283 | # REMOVE_END
|
282 | 284 |
|
283 | 285 | # STEP_START filter2
|
|
289 | 291 | # STEP_END
|
290 | 292 |
|
291 | 293 | # REMOVE_START
|
292 |
| -assert res9 == ['Weywot', 'Mimas'] |
| 294 | +assert res9 == ["Weywot", "Mimas"] |
293 | 295 | # REMOVE_END
|
294 | 296 |
|
295 | 297 | # STEP_START filter3
|
|
305 | 307 |
|
306 | 308 | # STEP_START filter4
|
307 | 309 | res11 = r.json().set(
|
308 |
| - "bikes:inventory", |
309 |
| - "$.inventory.mountain_bikes[0].regex_pat", |
310 |
| - "(?i)al" |
| 310 | + "bikes:inventory", "$.inventory.mountain_bikes[0].regex_pat", "(?i)al" |
311 | 311 | )
|
312 | 312 | res12 = r.json().set(
|
313 |
| - "bikes:inventory", |
314 |
| - "$.inventory.mountain_bikes[1].regex_pat", |
315 |
| - "(?i)al" |
| 313 | + "bikes:inventory", "$.inventory.mountain_bikes[1].regex_pat", "(?i)al" |
316 | 314 | )
|
317 | 315 | res13 = r.json().set(
|
318 |
| - "bikes:inventory", |
319 |
| - "$.inventory.mountain_bikes[2].regex_pat", |
320 |
| - "(?i)al" |
| 316 | + "bikes:inventory", "$.inventory.mountain_bikes[2].regex_pat", "(?i)al" |
321 | 317 | )
|
322 | 318 |
|
323 | 319 | res14 = r.json().get(
|
|
328 | 324 | # STEP_END
|
329 | 325 |
|
330 | 326 | # REMOVE_START
|
331 |
| -assert res14 == ['Quaoar', 'Weywot'] |
| 327 | +assert res14 == ["Quaoar", "Weywot"] |
332 | 328 | # REMOVE_END
|
333 | 329 |
|
334 | 330 | # STEP_START update_bikes
|
|
349 | 345 | # REMOVE_END
|
350 | 346 |
|
351 | 347 | # STEP_START update_filters1
|
352 |
| -res18 = r.json().set("bikes:inventory", "$.inventory.*[?(@.price<2000)].price", 1500) |
| 348 | +res18 = r.json().set( |
| 349 | + "bikes:inventory", "$.inventory.*[?(@.price<2000)].price", 1500 |
| 350 | +) |
353 | 351 | res19 = r.json().get("bikes:inventory", "$..price")
|
354 | 352 | print(res19) # >>> [1500, 2072, 3264, 1500, 3941]
|
355 | 353 | # STEP_END
|
|
0 commit comments