From 0a8df7fde2b81e10b64bd419c947a8b49f8bfde2 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Thu, 1 Feb 2018 15:37:38 -0500 Subject: [PATCH] work around a bug in dateutil that incorrectly parses Z dates related: https://github.com/dateutil/dateutil/issues/349 --- awx/main/models/schedules.py | 2 +- awx/main/tests/functional/models/test_schedule.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/awx/main/models/schedules.py b/awx/main/models/schedules.py index 59629c89a7..de4c164e65 100644 --- a/awx/main/models/schedules.py +++ b/awx/main/models/schedules.py @@ -127,7 +127,7 @@ class Schedule(CommonModel, LaunchTimeConfig): https://github.com/dateutil/dateutil/pull/619 """ kwargs['forceset'] = True - kwargs['tzinfos'] = {} + kwargs['tzinfos'] = {x: dateutil.tz.tzutc() for x in dateutil.parser.parserinfo().UTCZONE} match = cls.TZID_REGEX.match(rrule) if match is not None: rrule = cls.TZID_REGEX.sub("DTSTART\gTZI\g", rrule) diff --git a/awx/main/tests/functional/models/test_schedule.py b/awx/main/tests/functional/models/test_schedule.py index 3768058f4f..ff37667371 100644 --- a/awx/main/tests/functional/models/test_schedule.py +++ b/awx/main/tests/functional/models/test_schedule.py @@ -146,15 +146,16 @@ def test_tzinfo_naive_until(job_template, dtstart, until): @pytest.mark.django_db -def test_mismatched_until_timezone(job_template): - rrule = 'DTSTART;TZID=America/New_York:20180601T120000 RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20180602T000000' + 'Z' # noqa the Z isn't allowed, because we have a TZID=America/New_York +def test_until_must_be_utc(job_template): + rrule = 'DTSTART;TZID=America/New_York:20180601T120000 RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20180602T000000' # noqa the Z is required s = Schedule( name='Some Schedule', rrule=rrule, unified_job_template=job_template ) - with pytest.raises(ValueError): + with pytest.raises(ValueError) as e: s.save() + assert 'RRULE UNTIL values must be specified in UTC' in str(e) @pytest.mark.django_db