Revert "First steps into pytz deprecation"

This reverts commit e4e7d50659.
This commit is contained in:
Raphael Michel
2023-02-01 13:15:18 +01:00
parent e4e7d50659
commit 59d46ddded
63 changed files with 362 additions and 341 deletions

View File

@@ -37,7 +37,6 @@ 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
@@ -45,6 +44,7 @@ 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(ZoneInfo(self.event.settings.timezone)).strftime(fmt)),
self.event.date_from.astimezone(timezone(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(ZoneInfo(self.event.settings.timezone)).strftime(fmt)),
self.event.date_to.astimezone(timezone(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(ZoneInfo(self.event.settings.timezone)).strftime(fmt)),
self.event.date_from.astimezone(timezone(self.event.settings.timezone)).strftime(fmt)),
ical, 'incorrect start time')
self.assertNotIn('DTEND', ical, 'unexpected end time attribute')

View File

@@ -19,11 +19,12 @@
# 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, timezone
from datetime import datetime, timedelta
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
@@ -148,7 +149,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=timezone.utc),
date_from=datetime(now().year + 1, 9, 1, tzinfo=UTC),
live=True, is_public=False
)
r = client.get('/mrmcd/?style=calendar')
@@ -168,7 +169,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=timezone.utc),
date_from=datetime(now().year + 1, 9, 1, tzinfo=UTC),
live=True, is_public=False
)
r = client.get('/mrmcd/?style=week')
@@ -186,7 +187,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=timezone.utc),
date_from=datetime(now().year + 1, 9, 1, tzinfo=UTC),
live=True, is_public=True
)
prop = env[0].meta_properties.create(name='loc')
@@ -202,7 +203,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=timezone.utc),
date_from=datetime(now().year + 1, 9, 1, tzinfo=UTC),
live=True, is_public=False
)
r = client.get('/mrmcd/events/ical/')
@@ -217,7 +218,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=timezone.utc),
date_from=datetime(now().year + 1, 9, 1, tzinfo=UTC),
live=True, is_public=True, has_subevents=True
)
with scopes_disabled():
@@ -231,12 +232,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=timezone.utc),
date_from=datetime(now().year + 1, 9, 1, tzinfo=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=timezone.utc),
date_from=datetime(now().year + 1, 9, 1, tzinfo=UTC),
live=True, is_public=True, has_subevents=True
)
with scopes_disabled():