You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
720 B

  1. from datetime import timedelta as td
  2. from django.test import TestCase
  3. from hc.lib.date import format_hms
  4. class DateFormattingTestCase(TestCase):
  5. def test_mins_secs_work(self):
  6. s = format_hms(td(seconds=0))
  7. self.assertEqual(s, "0 sec")
  8. s = format_hms(td(seconds=1))
  9. self.assertEqual(s, "1 sec")
  10. s = format_hms(td(seconds=61))
  11. self.assertEqual(s, "1 min 1 sec")
  12. s = format_hms(td(seconds=62))
  13. self.assertEqual(s, "1 min 2 sec")
  14. def test_hours_work(self):
  15. s = format_hms(td(seconds=62 + 60 * 60))
  16. self.assertEqual(s, "1 h 1 min 2 sec")
  17. s = format_hms(td(seconds=60 * 60))
  18. self.assertEqual(s, "1 h 0 min 0 sec")