Skip to content

Commit

Permalink
Fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cisc0f committed Apr 1, 2024
1 parent 0829fc8 commit 38db5dc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion service/models/shop_cart_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def find_by_product_id(cls, product_id):
product_id (string): the product_id of the ShopCart Item you want to match
"""
logger.info("Processing lookup for product_id: %s", product_id)
return cls.query.session.get(cls, product_id)
return cls.query.filter(cls.product_id == product_id).first()

# @classmethod
# def find_by_shopcart_id(cls, shopcart_id):
Expand Down
2 changes: 1 addition & 1 deletion service/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def get_shopcart_items(shopcart_id, item_id):
######################################################################
# RETRIEVE AN ITEM FROM SHOPCART BY PRODUCT ID
######################################################################
@app.route("/shopcarts/<int:shopcart_id>/items/<int:product_id>", methods=["GET"])
@app.route("/shopcarts/<int:shopcart_id>/products/<int:product_id>", methods=["GET"])
def get_shopcart_items_by_product_id(shopcart_id, product_id):
"""
Get an Item
Expand Down
2 changes: 1 addition & 1 deletion tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def test_get_shopcart_item_by_product_id(self):

# retrieve it back
resp = self.client.get(
f"{BASE_URL}/{shopcart.id}/items/{product_id}",
f"{BASE_URL}/{shopcart.id}/products/{product_id}",
content_type="application/json",
)
self.assertEqual(resp.status_code, status.HTTP_200_OK)
Expand Down

0 comments on commit 38db5dc

Please sign in to comment.