diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a96c54e..177a20e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,8 +7,7 @@ jobs: build: strategy: matrix: - python-version: [3.7, 3.8, 3.9, "3.10", 3.11] - + python-version: [3.8, 3.9, "3.10", 3.11] runs-on: ubuntu-latest steps: diff --git a/pydoof/search_api/stats.py b/pydoof/search_api/stats.py index b897d32..0a4e811 100644 --- a/pydoof/search_api/stats.py +++ b/pydoof/search_api/stats.py @@ -143,41 +143,3 @@ def add_to_cart( api_client = client or SearchAPIClient(**opts) return api_client.put(f"/6/{hashid}/stats/cart/{session_id}", query_params=query_params) - - -def remove_from_cart( - hashid: str, - index_name: str, - session_id: str, - item_id: str, - amount: int, - client=None, - **opts, -): - """ - Removes amount from the given item in the cart, and deletes if the result - is lower than 0. - - Args: - hashid: Unique search engine id. Indicates to which search engine we are doing the query. - session_id (<= 32 characters): The current session ID, must be unique for each user. - index_name: The index used for this product in Doofinder. - item_id: The ID of the item to be added (this refers to the ID in the shop database). - amount: Amount of items to add to the cart. - """ - query_params = {"index": index_name, "id": item_id, "amount": amount} - - api_client = client or SearchAPIClient(**opts) - return api_client.patch(f"/6/{hashid}/stats/cart/{session_id}", query_params=query_params) - - -def clear_cart(hashid: str, session_id: str, client=None, **opts): - """ - Deletes the cart with all its content. - - Args: - hashid: Unique search engine id. Indicates to which search engine we are doing the query. - session_id (<= 32 characters): The current session ID, must be unique for each user. - """ - api_client = client or SearchAPIClient(**opts) - return api_client.delete(f"/6/{hashid}/stats/cart/{session_id}") diff --git a/pyproject.toml b/pyproject.toml index 137d3b2..b259fbd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,7 @@ [tool.ruff] line-length = 119 indent-width = 4 +target-version = "py38" [tool.ruff.lint] extend-select = [ @@ -9,3 +10,7 @@ extend-select = [ "E", # pyflakes "TRY", ] + +[tool.ruff.lint.pyupgrade] +# Keep compatibility with Python 3.8 +keep-runtime-typing = true diff --git a/tests/search_api/test_stats.py b/tests/search_api/test_stats.py index 9853a10..655c7ce 100644 --- a/tests/search_api/test_stats.py +++ b/tests/search_api/test_stats.py @@ -151,32 +151,4 @@ def test_add_to_cart(self, APIClientMock): query_params={ 'index': index_name, 'id': item_id, 'amount': amount, 'title': title, 'price': price} - ) - - @mock.patch('pydoof.search_api.stats.SearchAPIClient') - def test_remove_from_cart(self, APIClientMock): - hashid = 'aab32d8' - index_name = 'product' - session_id = '4affa6' - amount = 2 - item_id = 1235 - - stats.remove_from_cart( - hashid, index_name, session_id, item_id, amount - ) - - APIClientMock.return_value.patch.assert_called_once_with( - f'/6/{hashid}/stats/cart/{session_id}', - query_params={'index': index_name, 'id': item_id, 'amount': amount} - ) - - @mock.patch('pydoof.search_api.stats.SearchAPIClient') - def test_clear_cart(self, APIClientMock): - hashid = 'aab32d8' - session_id = '4affa6' - - stats.clear_cart(hashid, session_id) - - APIClientMock.return_value.delete.assert_called_once_with( - f'/6/{hashid}/stats/cart/{session_id}' - ) + ) \ No newline at end of file