From 38db5dc7672dc839099e27de0ec1672b089c55a1 Mon Sep 17 00:00:00 2001 From: cisc0f Date: Sun, 31 Mar 2024 22:30:01 -0400 Subject: [PATCH] Fixed bug --- service/models/shop_cart_item.py | 2 +- service/routes.py | 2 +- tests/test_routes.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/service/models/shop_cart_item.py b/service/models/shop_cart_item.py index 02211e9..52362db 100644 --- a/service/models/shop_cart_item.py +++ b/service/models/shop_cart_item.py @@ -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): diff --git a/service/routes.py b/service/routes.py index 4d6b360..8cf2f4c 100644 --- a/service/routes.py +++ b/service/routes.py @@ -254,7 +254,7 @@ def get_shopcart_items(shopcart_id, item_id): ###################################################################### # RETRIEVE AN ITEM FROM SHOPCART BY PRODUCT ID ###################################################################### -@app.route("/shopcarts//items/", methods=["GET"]) +@app.route("/shopcarts//products/", methods=["GET"]) def get_shopcart_items_by_product_id(shopcart_id, product_id): """ Get an Item diff --git a/tests/test_routes.py b/tests/test_routes.py index 3f21b29..af6a62f 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -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)