def get_duration(self, obj): return calculate_duration_time(obj.start, obj.end)
def test_duration_time_minutes(): start = timezone.now() end = start + datetime.timedelta(minutes=10) duration = calculate_duration_time(start, end) assert duration == "0h10m0s"
def test_duration_time_hours(): start = timezone.now() end = start + datetime.timedelta(hours=2) duration = calculate_duration_time(start, end) assert duration == "2h0m0s"
def test_duration_time_various_days(): start = timezone.now() end = start + datetime.timedelta(days=3, hours=5, minutes=16, seconds=55) duration = calculate_duration_time(start, end) assert duration == "77h16m55s"
def test_duration_time_seconds(): start = timezone.now() end = start + datetime.timedelta(seconds=35) duration = calculate_duration_time(start, end) assert duration == "0h0m35s"