M src/groceries/web/api.py => src/groceries/web/api.py +1 -1
@@ 66,7 66,7 @@ def get_item(name):
return dictify(item)
-@bp.route("/items/<name>", methods=["PUT"])
+@bp.route("/items/<name>", methods=["PATCH"])
def update_item(name):
grocery_list = GroceryList(current_app.config["BACKEND"])
M tests/test_rest_server.py => tests/test_rest_server.py +3 -3
@@ 124,7 124,7 @@ def test_create_existing_item(client):
def test_update_item(client):
item = client.get("/api/items/apples").get_json()
- response = client.put("/api/items/apples", json={"section": "fruit"})
+ response = client.patch("/api/items/apples", json={"section": "fruit"})
assert response.status_code == 200
expected = dict(item, section="fruit")
assert response.get_json() == expected
@@ 132,7 132,7 @@ def test_update_item(client):
def test_update_unknown_item(client):
- response = client.put("/api/items/jabberwocky", json={"section": "pets"})
+ response = client.patch("/api/items/jabberwocky", json={"section": "pets"})
assert response.status_code == 404
assert response.get_json() == {
"error": "404 Not Found: 'jabberwocky' not found in grocery list."
@@ 140,7 140,7 @@ def test_update_unknown_item(client):
def test_update_item_with_invalid_fields(client):
- response = client.put("/api/items/apples", json={"variety": "granny smith"})
+ response = client.patch("/api/items/apples", json={"variety": "granny smith"})
assert response.status_code == 400
assert response.get_json() == {
"error": "400 Bad Request: Invalid fields in request"