From cd3bf697e8f31b5f8ce1704af3cee0ad3c1a598c Mon Sep 17 00:00:00 2001 From: Blue Date: Thu, 3 Feb 2022 23:46:16 -0800 Subject: [PATCH] Force PST in the tests --- events/__init__.py | 3 +-- events/test_events.py | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/events/__init__.py b/events/__init__.py index b6930e4..0fc5bd9 100644 --- a/events/__init__.py +++ b/events/__init__.py @@ -106,7 +106,6 @@ def get_event_fields(event): if 'dtstart' in component: start = component['dtstart'].dt event['start'] = format_time(start) - if not isinstance(start, datetime): start = datetime.combine(start, datetime.min.time()) @@ -149,7 +148,7 @@ def render_event(collection_id, event_id, event_data, **extra_fields): fields = get_event_fields(event_data) fields['collection'] = collection_id fields['event'] = event_id - fields['server_timezone'] = get_localzone().zone + fields['server_timezone'] = settings.timezone.zone add_request_auth(fields) for e in extra_fields: diff --git a/events/test_events.py b/events/test_events.py index 4069b7f..bb34ed3 100644 --- a/events/test_events.py +++ b/events/test_events.py @@ -3,6 +3,7 @@ import pytest import json import pytz +import time import email from threading import Thread from ecdsa import SigningKey @@ -19,6 +20,9 @@ from flask.testing import FlaskClient as BaseFlaskClient +os.environ['TZ'] = 'America/Los_Angeles' +time.tzset() + event_1 = Event() event_1.add('dtstart', datetime(2010, 10, 10, 10, 0, 0)) event_1['summary'] = 'event_1' @@ -144,7 +148,7 @@ class Config: external_url = 'http://127.0.0.1:1111' signing_key = SigningKey.generate() - timezone = pytz.timezone('US/Pacific') + timezone = pytz.timezone(os.environ['TZ']) def is_admin(self, request): return request.headers.get('X-Admin', None) == 'true'