diff --git a/tests/test_product.py b/tests/test_product.py index 52b7528..c135cc2 100644 --- a/tests/test_product.py +++ b/tests/test_product.py @@ -220,6 +220,8 @@ def test_products_pagination(self, create_product): data1 = resp1.get_json() assert "products" in data1 assert len(data1["products"]) == 10 + assert data1["cursor"]["prev"] is None + assert isinstance(data1["cursor"]["next"], str) # Page 2 next_cursor = data1["cursor"]["next"] @@ -228,3 +230,5 @@ def test_products_pagination(self, create_product): data2 = resp2.get_json() assert "products" in data2 assert len(data2["products"]) == 5 + assert data2["cursor"]["next"] is None + assert isinstance(data2["cursor"]["prev"], str) diff --git a/tests/test_relationships.py b/tests/test_relationships.py index 173fd45..1c090e0 100644 --- a/tests/test_relationships.py +++ b/tests/test_relationships.py @@ -219,8 +219,13 @@ def test_get_category_products_populated_with_pagination(self, create_category, product_ids.add(product_resp.get_json().get("id")) page1 = self.client.get(f"/categories/{category['id']}/products").get_json() + assert page1["cursor"]["prev"] is None + assert type(page1["cursor"]["next"]) is str + next_cursor = page1["cursor"]["next"] page2 = self.client.get(f"/categories/{category['id']}/products?cursor={next_cursor}").get_json() + assert page2["cursor"]["next"] is None + assert isinstance(page2["cursor"]["prev"], str) assert len(page1["products"]) == 10 assert len(page2["products"]) == 2 @@ -254,8 +259,13 @@ def test_get_subcategory_products_populated_with_pagination(self, create_subcate product_ids.add(product_resp.get_json().get("id")) page1 = self.client.get(f"/subcategories/{subcategory['id']}/products").get_json() + assert page1["cursor"]["prev"] is None + assert type(page1["cursor"]["next"]) is str + next_cursor = page1["cursor"]["next"] page2 = self.client.get(f"/subcategories/{subcategory['id']}/products?cursor={next_cursor}").get_json() + assert page2["cursor"]["next"] is None + assert isinstance(page2["cursor"]["prev"], str) assert len(page1["products"]) == 10 assert len(page2["products"]) == 1