Add Duck.dpx() method
This commit is contained in:
parent
e12019723d
commit
56d19e07d9
@ -62,6 +62,15 @@ class Duck(models.Model):
|
|||||||
|
|
||||||
return seconds
|
return seconds
|
||||||
|
|
||||||
|
def dpx(self):
|
||||||
|
all_time = Booking.total_booking_time()
|
||||||
|
duck_time = Booking.duck_booking_time(self)
|
||||||
|
|
||||||
|
if (all_time == None) or (duck_time == None):
|
||||||
|
return 0
|
||||||
|
|
||||||
|
return Booking.duck_booking_time(self) / Booking.total_booking_time()
|
||||||
|
|
||||||
class DuckName(models.Model):
|
class DuckName(models.Model):
|
||||||
"""Model to hold name suggestions for Ducks"""
|
"""Model to hold name suggestions for Ducks"""
|
||||||
|
|
||||||
|
@ -188,3 +188,7 @@ class BookingTimeTest(TestCase):
|
|||||||
def test_duck_booking_time(self):
|
def test_duck_booking_time(self):
|
||||||
self.assertEqual(Booking.duck_booking_time(self.duck1), 86400)
|
self.assertEqual(Booking.duck_booking_time(self.duck1), 86400)
|
||||||
self.assertEqual(Booking.duck_booking_time(self.duck2), 172800)
|
self.assertEqual(Booking.duck_booking_time(self.duck2), 172800)
|
||||||
|
|
||||||
|
def test_dpx(self):
|
||||||
|
self.assertEqual(self.duck1.dpx(), 1/3)
|
||||||
|
self.assertEqual(self.duck2.dpx(), 2/3)
|
||||||
|
Loading…
Reference in New Issue
Block a user