1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

work around a bug in dateutil that incorrectly parses Z dates

related: https://github.com/dateutil/dateutil/issues/349
This commit is contained in:
Ryan Petrello 2018-02-01 15:37:38 -05:00
parent b39269c4c2
commit 0a8df7fde2
No known key found for this signature in database
GPG Key ID: F2AA5F2122351777
2 changed files with 5 additions and 4 deletions

View File

@ -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\g<stamp>TZI\g<rrule>", rrule)

View File

@ -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