From b9bf9f2a64e42b4beebc5eab7da5c1ea98d05135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noah=20Gro=C3=9F?= Date: Wed, 5 Aug 2026 20:51:58 +0200 Subject: [PATCH 1/3] fix: supply client version for cart operations PicNic suddenly requires a client version for cart operations. --- src/python_picnic_api2/client.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/python_picnic_api2/client.py b/src/python_picnic_api2/client.py index 9ecf4d9..d13f1f1 100644 --- a/src/python_picnic_api2/client.py +++ b/src/python_picnic_api2/client.py @@ -176,7 +176,7 @@ def search(self, term: str) -> SearchResult: return SearchResult.from_page(raw_results) def get_cart(self) -> Cart: - return Cart.from_api(self._get("/cart")) + return Cart.from_api(self._get("/cart", add_picnic_headers=True)) def get_article(self, article_id: str, add_category=False) -> Article | None: path = f"/pages/product-details-page-root?id={article_id}" + \ @@ -212,14 +212,14 @@ def get_article_category(self, article_id: str): def add_product(self, product_id: str, count: int = 1) -> Cart: data = {"product_id": product_id, "count": count} - return Cart.from_api(self._post("/cart/add_product", data)) + return Cart.from_api(self._post("/cart/add_product", data, add_picnic_headers=True)) def remove_product(self, product_id: str, count: int = 1) -> Cart: data = {"product_id": product_id, "count": count} - return Cart.from_api(self._post("/cart/remove_product", data)) + return Cart.from_api(self._post("/cart/remove_product", data, add_picnic_headers=True)) def clear_cart(self) -> Cart: - return Cart.from_api(self._post("/cart/clear")) + return Cart.from_api(self._post("/cart/clear", add_picnic_headers=True)) def get_delivery_slots(self) -> DeliverySlots: return DeliverySlots.from_api(self._get("/cart/delivery_slots")) From 337118f5c2267bb85c81765fbf93cbcadbd2c807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noah=20Gro=C3=9F?= Date: Wed, 5 Aug 2026 21:00:05 +0200 Subject: [PATCH 2/3] test: expect picnic version headers for cart ops --- tests/test_client.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_client.py b/tests/test_client.py index 53ffdf5..6b73f24 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -254,7 +254,8 @@ def test_get_cart(self): ) cart = self.client.get_cart() self.session_mock().get.assert_called_with( - self.expected_base_url + "/cart", headers=None + self.expected_base_url + "/cart", + headers=PICNIC_HEADERS, ) self.assertEqual(cart.type, "ORDER") self.assertEqual(cart.total_count, 3) @@ -267,6 +268,7 @@ def test_add_product(self): self.session_mock().post.assert_called_with( self.expected_base_url + "/cart/add_product", json={"product_id": "p3f2qa", "count": 1}, + headers=PICNIC_HEADERS, ) self.assertEqual(cart.type, "ORDER") @@ -278,6 +280,7 @@ def test_add_multiple_products(self): self.session_mock().post.assert_called_with( self.expected_base_url + "/cart/add_product", json={"product_id": "gs4puhf3a", "count": 5}, + headers=PICNIC_HEADERS, ) def test_remove_product(self): @@ -288,6 +291,7 @@ def test_remove_product(self): self.session_mock().post.assert_called_with( self.expected_base_url + "/cart/remove_product", json={"product_id": "gs4puhf3a", "count": 5}, + headers=PICNIC_HEADERS, ) def test_clear_cart(self): @@ -296,7 +300,9 @@ def test_clear_cart(self): ) cart = self.client.clear_cart() self.session_mock().post.assert_called_with( - self.expected_base_url + "/cart/clear", json=None + self.expected_base_url + "/cart/clear", + json=None, + headers=PICNIC_HEADERS, ) self.assertEqual(cart.type, "ORDER") From f88d88fd38bff6138df07e19fadfba7366123a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noah=20Gro=C3=9F?= Date: Wed, 5 Aug 2026 21:03:14 +0200 Subject: [PATCH 3/3] style: ruff formatting --- src/python_picnic_api2/client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/python_picnic_api2/client.py b/src/python_picnic_api2/client.py index d13f1f1..4d45668 100644 --- a/src/python_picnic_api2/client.py +++ b/src/python_picnic_api2/client.py @@ -212,11 +212,13 @@ def get_article_category(self, article_id: str): def add_product(self, product_id: str, count: int = 1) -> Cart: data = {"product_id": product_id, "count": count} - return Cart.from_api(self._post("/cart/add_product", data, add_picnic_headers=True)) + return Cart.from_api(self._post("/cart/add_product", data, + add_picnic_headers=True)) def remove_product(self, product_id: str, count: int = 1) -> Cart: data = {"product_id": product_id, "count": count} - return Cart.from_api(self._post("/cart/remove_product", data, add_picnic_headers=True)) + return Cart.from_api(self._post("/cart/remove_product", data, + add_picnic_headers=True)) def clear_cart(self) -> Cart: return Cart.from_api(self._post("/cart/clear", add_picnic_headers=True))