Add test for short datetime template tag

This commit is contained in:
Christopher C. Wells 2021-07-31 20:22:07 -07:00 committed by Christopher Charbonneau Wells
parent 16c34ca7f0
commit 273c365bef
1 changed files with 15 additions and 1 deletions

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from django.contrib.auth.models import User
from django.test import TestCase
from django.utils import timezone
from django.utils import timezone, formats
from core.models import Child, Timer
from core.templatetags import bootstrap, datetime, duration, timers
@ -83,3 +83,17 @@ class TemplateTagsTestCase(TestCase):
datetime.datetimepicker_format('L LT'), 'L HH:mm')
self.assertEqual(
datetime.datetimepicker_format('L LTS'), 'L HH:mm:ss')
def test_datetime_short(self):
date = timezone.localtime()
self.assertEqual(datetime.datetime_short(date), "Today, {}".format(
formats.date_format(date, format='TIME_FORMAT')))
date = timezone.localtime() - timezone.timedelta(days=1, hours=6)
self.assertEqual(datetime.datetime_short(date), "{}, {}".format(
formats.date_format(date, format='SHORT_MONTH_DAY_FORMAT'),
formats.date_format(date, format='TIME_FORMAT')))
date = timezone.localtime() - timezone.timedelta(days=500)
self.assertEqual(datetime.datetime_short(date), formats.date_format(
date, format='SHORT_DATETIME_FORMAT'))