|
@ -1,20 +1,27 @@ |
|
|
from datetime import timedelta as td |
|
|
from datetime import timedelta as td |
|
|
from django.test import TestCase |
|
|
from django.test import TestCase |
|
|
|
|
|
|
|
|
from hc.lib.date import format_mins_secs |
|
|
|
|
|
|
|
|
from hc.lib.date import format_hms |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DateFormattingTestCase(TestCase): |
|
|
class DateFormattingTestCase(TestCase): |
|
|
|
|
|
|
|
|
def test_mins_secs_work(self): |
|
|
def test_mins_secs_work(self): |
|
|
s = format_mins_secs(td(seconds=0)) |
|
|
|
|
|
|
|
|
s = format_hms(td(seconds=0)) |
|
|
self.assertEqual(s, "0 sec") |
|
|
self.assertEqual(s, "0 sec") |
|
|
|
|
|
|
|
|
s = format_mins_secs(td(seconds=1)) |
|
|
|
|
|
|
|
|
s = format_hms(td(seconds=1)) |
|
|
self.assertEqual(s, "1 sec") |
|
|
self.assertEqual(s, "1 sec") |
|
|
|
|
|
|
|
|
s = format_mins_secs(td(seconds=61)) |
|
|
|
|
|
|
|
|
s = format_hms(td(seconds=61)) |
|
|
self.assertEqual(s, "1 min 1 sec") |
|
|
self.assertEqual(s, "1 min 1 sec") |
|
|
|
|
|
|
|
|
s = format_mins_secs(td(seconds=62)) |
|
|
|
|
|
|
|
|
s = format_hms(td(seconds=62)) |
|
|
self.assertEqual(s, "1 min 2 sec") |
|
|
self.assertEqual(s, "1 min 2 sec") |
|
|
|
|
|
|
|
|
|
|
|
def test_hours_work(self): |
|
|
|
|
|
s = format_hms(td(seconds=62 + 60 * 60)) |
|
|
|
|
|
self.assertEqual(s, "1 h 1 min 2 sec") |
|
|
|
|
|
|
|
|
|
|
|
s = format_hms(td(seconds=60 * 60)) |
|
|
|
|
|
self.assertEqual(s, "1 h 0 min 0 sec") |