From 0fd78269364f0d801c6293dd6da45037ae8cd1f9 Mon Sep 17 00:00:00 2001 From: Jan Gregorczyk Date: Sat, 16 Mar 2024 16:54:27 +0100 Subject: [PATCH] test: fixed min max products filters tests --- .../tests/test_products_filters.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dshop/apps/products_catalogue/tests/test_products_filters.py b/Dshop/apps/products_catalogue/tests/test_products_filters.py index 6133c58..f244043 100644 --- a/Dshop/apps/products_catalogue/tests/test_products_filters.py +++ b/Dshop/apps/products_catalogue/tests/test_products_filters.py @@ -91,19 +91,19 @@ def test_filter_category(client, products): @pytest.mark.django_db def test_filter_by_min_price(client, products): url = reverse("products-list") - response = client.get(f"{url}?prince__gt=5") + response = client.get(f"{url}?price__gt=5") products = response.context['object_list'] - for value in range(5, 10): - assert products[value].price == Decimal(value + 1) + for value, product in enumerate(products, start=6): + assert product.price == value @pytest.mark.django_db def test_filter_by_max_price(client, products): url = reverse("products-list") - response = client.get(f"{url}?prince__lt=5") + response = client.get(f"{url}?price__lt=5") products = response.context['object_list'] - for idx, value in enumerate(range(5)): - assert products[idx].price == Decimal(value + 1) + for value, product in enumerate(products, start=1): + assert product.price == value @pytest.mark.django_db