def test_return_value(self): self.assertEqual(format_minutes_to_time(1), u'00:01') self.assertEqual(format_minutes_to_time(15), u'00:15') self.assertEqual(format_minutes_to_time(60), u'01:00') self.assertEqual(format_minutes_to_time(61), u'01:01') self.assertEqual(format_minutes_to_time(600), u'10:00') self.assertEqual(format_minutes_to_time(601), u'10:01') self.assertEqual(format_minutes_to_time(611), u'10:11') self.assertEqual(format_minutes_to_time(671), u'11:11')
def get_booking_sum(self, day): # pylint: disable=R0201 """Display the booking time per day. The normal frontend validation will not allow more than 24 hours, but the backend should display a limit of 24 hours e.g. because of backend jobs that created more than 24 hours per day. """ duration = day.get_booking_sum() # TODO: Use constant variable if duration > 1440: color = 'red' else: color = 'black' value = format_minutes_to_time(duration) return '<span style="color: %s;">%s</span>' % (color, value)
def test_should_handle_empty_values(self): self.assertEqual(format_minutes_to_time(None), u'') self.assertEqual(format_minutes_to_time(False), u'')
def test_should_accept_decimal(self): value = decimal.Decimal(120) ret = format_minutes_to_time(value) self.assertEqual(ret, u'02:00')
def test_should_accept_integer(self): value = 120 ret = format_minutes_to_time(value) self.assertEqual(ret, u'02:00')
def get_duration(self, booking): # pylint: disable=R0201 return format_minutes_to_time(booking.duration)