From 8f258e31c7de91cf7e94bc266be536677763db0b Mon Sep 17 00:00:00 2001 From: K8sCat Date: Tue, 17 Oct 2023 10:33:30 +0800 Subject: [PATCH] add: unit test for CrontabSchedule Signed-off-by: K8sCat --- t/unit/test_schedulers.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/t/unit/test_schedulers.py b/t/unit/test_schedulers.py index dbafe666..a6b4da8a 100644 --- a/t/unit/test_schedulers.py +++ b/t/unit/test_schedulers.py @@ -19,6 +19,7 @@ IntervalSchedule, PeriodicTask, PeriodicTasks, SolarSchedule) from django_celery_beat.utils import NEVER_CHECK_TIMEOUT, make_aware +from django_celery_beat.tzcrontab import TzAwareCrontab _ids = count(0) @@ -668,6 +669,20 @@ def test_CrontabSchedule_unicode(self): month_of_year='4,6', )) == '3 3 */2 4,6 tue (m/h/dM/MY/d) UTC' + @override_settings( + DJANGO_CELERY_BEAT_TZ_AWARE=False + ) + def test_CrontabSchedule_schedule_crontab(self): + s = CrontabSchedule() + assert isinstance(s.schedule, crontab) + + @override_settings( + DJANGO_CELERY_BEAT_TZ_AWARE=True + ) + def test_CrontabSchedule_schedule_TzAwareCrontab(self): + s = CrontabSchedule() + assert isinstance(s.schedule, TzAwareCrontab) + def test_PeriodicTask_unicode_interval(self): p = self.create_model_interval(schedule(timedelta(seconds=10))) assert str(p) == f'{p.name}: every 10.0 seconds'