mirror of
https://github.com/ansible/awx.git
synced 2026-03-08 05:01:09 -02:30
work around a bug in dateutil that incorrectly parses Z dates
related: https://github.com/dateutil/dateutil/issues/349
This commit is contained in:
@@ -127,7 +127,7 @@ class Schedule(CommonModel, LaunchTimeConfig):
|
|||||||
https://github.com/dateutil/dateutil/pull/619
|
https://github.com/dateutil/dateutil/pull/619
|
||||||
"""
|
"""
|
||||||
kwargs['forceset'] = True
|
kwargs['forceset'] = True
|
||||||
kwargs['tzinfos'] = {}
|
kwargs['tzinfos'] = {x: dateutil.tz.tzutc() for x in dateutil.parser.parserinfo().UTCZONE}
|
||||||
match = cls.TZID_REGEX.match(rrule)
|
match = cls.TZID_REGEX.match(rrule)
|
||||||
if match is not None:
|
if match is not None:
|
||||||
rrule = cls.TZID_REGEX.sub("DTSTART\g<stamp>TZI\g<rrule>", rrule)
|
rrule = cls.TZID_REGEX.sub("DTSTART\g<stamp>TZI\g<rrule>", rrule)
|
||||||
|
|||||||
@@ -146,15 +146,16 @@ def test_tzinfo_naive_until(job_template, dtstart, until):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_mismatched_until_timezone(job_template):
|
def test_until_must_be_utc(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
|
rrule = 'DTSTART;TZID=America/New_York:20180601T120000 RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20180602T000000' # noqa the Z is required
|
||||||
s = Schedule(
|
s = Schedule(
|
||||||
name='Some Schedule',
|
name='Some Schedule',
|
||||||
rrule=rrule,
|
rrule=rrule,
|
||||||
unified_job_template=job_template
|
unified_job_template=job_template
|
||||||
)
|
)
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError) as e:
|
||||||
s.save()
|
s.save()
|
||||||
|
assert 'RRULE UNTIL values must be specified in UTC' in str(e)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
|
|||||||
Reference in New Issue
Block a user