Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Sep 15, 2024
1 parent aab4740 commit 998ff0a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
8 changes: 4 additions & 4 deletions open_prices/products/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
23 changes: 12 additions & 11 deletions open_prices/products/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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"),
Expand Down

0 comments on commit 998ff0a

Please sign in to comment.