diff --git a/open_prices/products/models.py b/open_prices/products/models.py index f4f055f2..34bac2d0 100644 --- a/open_prices/products/models.py +++ b/open_prices/products/models.py @@ -74,22 +74,22 @@ def update_price_count(self): self.price_count = self.prices.count() self.save(update_fields=["price_count"]) - def price_min(self, exclude_discounted=False): + def price__min(self, exclude_discounted=False): if exclude_discounted: return self.prices.exclude_discounted().calculate_min() return self.prices.calculate_min() - def price_max(self, exclude_discounted=False): + def price__max(self, exclude_discounted=False): if exclude_discounted: return self.prices.exclude_discounted().calculate_max() return self.prices.calculate_max() - def price_avg(self, exclude_discounted=False): + def price__avg(self, exclude_discounted=False): if exclude_discounted: return self.prices.exclude_discounted().calculate_avg() return self.prices.calculate_avg() - def price_stats(self, exclude_discounted=False): + def price__stats(self, exclude_discounted=False): if exclude_discounted: return self.prices.exclude_discounted().calculate_stats() return self.prices.calculate_stats() diff --git a/open_prices/products/tests.py b/open_prices/products/tests.py index 3b2a3e40..6a915044 100644 --- a/open_prices/products/tests.py +++ b/open_prices/products/tests.py @@ -111,20 +111,21 @@ def test_update_price_count(self): self.product.update_price_count() self.assertEqual(self.product.price_count, 0) - def test_price_min(self): - self.assertEqual(self.product.price_min(), 1.0) - self.assertEqual(self.product.price_min(exclude_discounted=True), 2.0) + def test_price__min(self): + self.assertEqual(self.product.price__min(), 1.0) + self.assertEqual(self.product.price__min(exclude_discounted=True), 2.0) - def test_price_max(self): - self.assertEqual(self.product.price_max(), 2.0) + def test_price__max(self): + self.assertEqual(self.product.price__max(), 2.0) + self.assertEqual(self.product.price__max(exclude_discounted=True), 2.0) - def test_price_avg(self): - self.assertEqual(self.product.price_avg(), 1.5) - self.assertEqual(self.product.price_avg(exclude_discounted=True), 2.0) + def test_price__avg(self): + self.assertEqual(self.product.price__avg(), 1.5) + self.assertEqual(self.product.price__avg(exclude_discounted=True), 2.0) - def test_price_stats(self): + def test_price__stats(self): self.assertEqual( - self.product.price_stats(), + self.product.price__stats(), { "price__count": 2, "price__min": Decimal("1.0"), @@ -133,7 +134,7 @@ def test_price_stats(self): }, ) self.assertEqual( - self.product.price_stats(exclude_discounted=True), + self.product.price__stats(exclude_discounted=True), { "price__count": 1, "price__min": Decimal("2.0"),