Skip to content

Commit

Permalink
DOC-3787 added flake8 formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-stark-redis committed May 15, 2024
1 parent a8791bf commit 5b11111
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions doctests/dt_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,7 @@

# STEP_START get_bikes
res2 = r.json().get("bikes:inventory", "$.inventory.*")
print(
res2
)
print(res2)
# >>> [[{'id': 'bike:1', 'model': 'Phoebe',
# >>> 'description': 'This is a mid-travel trail slayer...
# STEP_END
Expand Down Expand Up @@ -262,22 +260,26 @@
"bikes:inventory",
"$..mountain_bikes[?(@.price < 3000 && @.specs.weight < 10)]",
)
print(
res8
) # >>> [{'id': 'bike:2', 'model': 'Quaoar',
print(res8)
# >>> [{'id': 'bike:2', 'model': 'Quaoar',
# 'description': "Redesigned for the 2020 model year...
# STEP_END

# REMOVE_START
assert res8 == [{
'id': 'bike:2', 'model': 'Quaoar',
'description': "Redesigned for the 2020 model year, this bike impressed "
"our testers and is the best all-around trail bike we've ever tested. "
"The Shimano gear system effectively does away with an external cassette, "
"so is super low maintenance in terms of wear and tear. All in all it's "
"an impressive package for the price, making it very competitive.",
'price': 2072, 'specs': {'material': 'aluminium', 'weight': 7.9},
'colors': ['black', 'white']}]
assert res8 == [
{
'id': 'bike:2',
'model': 'Quaoar',
'description': "Redesigned for the 2020 model year, this bike impressed "
"our testers and is the best all-around trail bike we've ever tested. "
"The Shimano gear system effectively does away with an external cassette, "
"so is super low maintenance in terms of wear and tear. All in all it's "
"an impressive package for the price, making it very competitive.",
'price': 2072,
'specs': {'material': 'aluminium', 'weight': 7.9},
'colors': ['black', 'white']
}
]
# REMOVE_END

# STEP_START filter2
Expand All @@ -289,7 +291,7 @@
# STEP_END

# REMOVE_START
assert res9 == ['Weywot', 'Mimas']
assert res9 == ["Weywot", "Mimas"]
# REMOVE_END

# STEP_START filter3
Expand All @@ -305,19 +307,13 @@

# STEP_START filter4
res11 = r.json().set(
"bikes:inventory",
"$.inventory.mountain_bikes[0].regex_pat",
"(?i)al"
"bikes:inventory", "$.inventory.mountain_bikes[0].regex_pat", "(?i)al"
)
res12 = r.json().set(
"bikes:inventory",
"$.inventory.mountain_bikes[1].regex_pat",
"(?i)al"
"bikes:inventory", "$.inventory.mountain_bikes[1].regex_pat", "(?i)al"
)
res13 = r.json().set(
"bikes:inventory",
"$.inventory.mountain_bikes[2].regex_pat",
"(?i)al"
"bikes:inventory", "$.inventory.mountain_bikes[2].regex_pat", "(?i)al"
)

res14 = r.json().get(
Expand All @@ -328,7 +324,7 @@
# STEP_END

# REMOVE_START
assert res14 == ['Quaoar', 'Weywot']
assert res14 == ["Quaoar", "Weywot"]
# REMOVE_END

# STEP_START update_bikes
Expand All @@ -349,7 +345,9 @@
# REMOVE_END

# STEP_START update_filters1
res18 = r.json().set("bikes:inventory", "$.inventory.*[?(@.price<2000)].price", 1500)
res18 = r.json().set(
"bikes:inventory", "$.inventory.*[?(@.price<2000)].price", 1500
)
res19 = r.json().get("bikes:inventory", "$..price")
print(res19) # >>> [1500, 2072, 3264, 1500, 3941]
# STEP_END
Expand Down

0 comments on commit 5b11111

Please sign in to comment.