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.

22 lines
680 B

  1. from datetime import timedelta as td
  2. from unittest import TestCase
  3. from hc.front.templatetags.hc_extras import hc_duration
  4. class HcExtrasTestCase(TestCase):
  5. def test_hc_duration_works(self):
  6. samples = [
  7. (60, "1 minute"),
  8. (120, "2 minutes"),
  9. (3600, "1 hour"),
  10. (3660, "1 hour 1 minute"),
  11. (86400, "1 day"),
  12. (604800, "1 week"),
  13. (2419200, "4 weeks"),
  14. (2592000, "30 days"),
  15. (3801600, "44 days"),
  16. ]
  17. for seconds, expected_result in samples:
  18. result = hc_duration(td(seconds=seconds))
  19. self.assertEqual(result, expected_result)