forked from CGM_Public/pretix_original
First steps into pytz deprecation
This commit is contained in:
@@ -37,6 +37,7 @@ import datetime
|
||||
import re
|
||||
from decimal import Decimal
|
||||
from json import loads
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from django.conf import settings
|
||||
from django.core import mail
|
||||
@@ -44,7 +45,6 @@ from django.core.exceptions import ValidationError
|
||||
from django.test import TestCase
|
||||
from django.utils.timezone import now
|
||||
from django_scopes import scopes_disabled
|
||||
from pytz import timezone
|
||||
from tests.base import SoupTest
|
||||
from tests.testdummy.signals import FoobarSalesChannel
|
||||
|
||||
@@ -1390,11 +1390,11 @@ class EventIcalDownloadTest(EventTestMixin, SoupTest):
|
||||
fmt = '%Y%m%dT%H%M%S'
|
||||
self.assertIn('DTSTART;TZID=%s:%s' %
|
||||
(self.event.settings.timezone,
|
||||
self.event.date_from.astimezone(timezone(self.event.settings.timezone)).strftime(fmt)),
|
||||
self.event.date_from.astimezone(ZoneInfo(self.event.settings.timezone)).strftime(fmt)),
|
||||
ical, 'incorrect start time')
|
||||
self.assertIn('DTEND;TZID=%s:%s' %
|
||||
(self.event.settings.timezone,
|
||||
self.event.date_to.astimezone(timezone(self.event.settings.timezone)).strftime(fmt)),
|
||||
self.event.date_to.astimezone(ZoneInfo(self.event.settings.timezone)).strftime(fmt)),
|
||||
ical, 'incorrect end time')
|
||||
self.assertIn('TZID:%s' % self.event.settings.timezone, ical, 'missing VCALENDAR')
|
||||
|
||||
@@ -1413,7 +1413,7 @@ class EventIcalDownloadTest(EventTestMixin, SoupTest):
|
||||
fmt = '%Y%m%dT%H%M%S'
|
||||
self.assertIn('DTSTART;TZID=%s:%s' %
|
||||
(self.event.settings.timezone,
|
||||
self.event.date_from.astimezone(timezone(self.event.settings.timezone)).strftime(fmt)),
|
||||
self.event.date_from.astimezone(ZoneInfo(self.event.settings.timezone)).strftime(fmt)),
|
||||
ical, 'incorrect start time')
|
||||
self.assertNotIn('DTEND', ical, 'unexpected end time attribute')
|
||||
|
||||
|
||||
@@ -19,12 +19,11 @@
|
||||
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
import pytest
|
||||
from django.utils.timezone import now
|
||||
from django_scopes import scopes_disabled
|
||||
from pytz import UTC
|
||||
|
||||
from pretix.base.models import Event, Organizer
|
||||
|
||||
@@ -149,7 +148,7 @@ def test_calendar(env, client):
|
||||
env[0].settings.event_list_type = 'calendar'
|
||||
e = Event.objects.create(
|
||||
organizer=env[0], name='MRMCD2017', slug='2017',
|
||||
date_from=datetime(now().year + 1, 9, 1, tzinfo=UTC),
|
||||
date_from=datetime(now().year + 1, 9, 1, tzinfo=timezone.utc),
|
||||
live=True, is_public=False
|
||||
)
|
||||
r = client.get('/mrmcd/?style=calendar')
|
||||
@@ -169,7 +168,7 @@ def test_week_calendar(env, client):
|
||||
env[0].settings.event_list_type = 'calendar'
|
||||
e = Event.objects.create(
|
||||
organizer=env[0], name='MRMCD2017', slug='2017',
|
||||
date_from=datetime(now().year + 1, 9, 1, tzinfo=UTC),
|
||||
date_from=datetime(now().year + 1, 9, 1, tzinfo=timezone.utc),
|
||||
live=True, is_public=False
|
||||
)
|
||||
r = client.get('/mrmcd/?style=week')
|
||||
@@ -187,7 +186,7 @@ def test_attributes_in_calendar(env, client):
|
||||
env[0].settings.event_list_type = 'calendar'
|
||||
e = Event.objects.create(
|
||||
organizer=env[0], name='MRMCD2017', slug='2017',
|
||||
date_from=datetime(now().year + 1, 9, 1, tzinfo=UTC),
|
||||
date_from=datetime(now().year + 1, 9, 1, tzinfo=timezone.utc),
|
||||
live=True, is_public=True
|
||||
)
|
||||
prop = env[0].meta_properties.create(name='loc')
|
||||
@@ -203,7 +202,7 @@ def test_attributes_in_calendar(env, client):
|
||||
def test_ics(env, client):
|
||||
e = Event.objects.create(
|
||||
organizer=env[0], name='MRMCD2017', slug='2017',
|
||||
date_from=datetime(now().year + 1, 9, 1, tzinfo=UTC),
|
||||
date_from=datetime(now().year + 1, 9, 1, tzinfo=timezone.utc),
|
||||
live=True, is_public=False
|
||||
)
|
||||
r = client.get('/mrmcd/events/ical/')
|
||||
@@ -218,7 +217,7 @@ def test_ics(env, client):
|
||||
def test_ics_subevents(env, client):
|
||||
e = Event.objects.create(
|
||||
organizer=env[0], name='MRMCD2017', slug='2017',
|
||||
date_from=datetime(now().year + 1, 9, 1, tzinfo=UTC),
|
||||
date_from=datetime(now().year + 1, 9, 1, tzinfo=timezone.utc),
|
||||
live=True, is_public=True, has_subevents=True
|
||||
)
|
||||
with scopes_disabled():
|
||||
@@ -232,12 +231,12 @@ def test_ics_subevents(env, client):
|
||||
def test_ics_subevents_attributes(env, client):
|
||||
e0 = Event.objects.create(
|
||||
organizer=env[0], name='DS2017', slug='DS2017',
|
||||
date_from=datetime(now().year + 1, 9, 1, tzinfo=UTC),
|
||||
date_from=datetime(now().year + 1, 9, 1, tzinfo=timezone.utc),
|
||||
live=True, is_public=True
|
||||
)
|
||||
e = Event.objects.create(
|
||||
organizer=env[0], name='MRMCD2017', slug='2017',
|
||||
date_from=datetime(now().year + 1, 9, 1, tzinfo=UTC),
|
||||
date_from=datetime(now().year + 1, 9, 1, tzinfo=timezone.utc),
|
||||
live=True, is_public=True, has_subevents=True
|
||||
)
|
||||
with scopes_disabled():
|
||||
|
||||
Reference in New Issue
Block a user