From 9257f68fd81e45b701b963425c9fcc72797957ea Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 13 May 2019 13:20:56 -0400 Subject: [PATCH] The default TIME_ZONE should be UTC In production, we use UTC as the time zone. DRF 3.7.7 now puts all times in the currently set timezone where it used to use UTC. By setting TIME_ZONE to UTC, we keep the same results we used to get. In a few places, we had to change the expected test results to be UTC. --- cms/envs/common.py | 2 +- .../program_enrollments/api/v1/tests/test_views.py | 4 ++-- lms/envs/common.py | 2 +- openedx/features/content_type_gating/tests/test_models.py | 6 +++--- .../features/course_duration_limits/tests/test_models.py | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cms/envs/common.py b/cms/envs/common.py index 33be61f1af..39478d627e 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -680,7 +680,7 @@ STATICFILES_DIRS = [ # Locale/Internationalization CELERY_TIMEZONE = 'UTC' -TIME_ZONE = 'America/New_York' # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +TIME_ZONE = 'UTC' LANGUAGE_CODE = 'en' # http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGES_BIDI = lms.envs.common.LANGUAGES_BIDI diff --git a/lms/djangoapps/program_enrollments/api/v1/tests/test_views.py b/lms/djangoapps/program_enrollments/api/v1/tests/test_views.py index ec25886b45..adfa913096 100644 --- a/lms/djangoapps/program_enrollments/api/v1/tests/test_views.py +++ b/lms/djangoapps/program_enrollments/api/v1/tests/test_views.py @@ -1738,8 +1738,8 @@ class ProgramCourseEnrollmentOverviewViewTests(ProgramCacheTestCaseMixin, Shared course_run_overview = response.data['course_runs'][0] - self.assertEqual(course_run_overview['start_date'], '2018-12-31T05:00:00Z') - self.assertEqual(course_run_overview['end_date'], '2019-01-02T05:00:00Z') + self.assertEqual(course_run_overview['start_date'], '2018-12-31T00:00:00Z') + self.assertEqual(course_run_overview['end_date'], '2019-01-02T00:00:00Z') # course run end date may not exist self.course_overview.end = None diff --git a/lms/envs/common.py b/lms/envs/common.py index 7c5cec67f2..51ca49e960 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -994,7 +994,7 @@ MEDIA_URL = '/media/' # Locale/Internationalization CELERY_TIMEZONE = 'UTC' -TIME_ZONE = 'America/New_York' # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +TIME_ZONE = 'UTC' LANGUAGE_CODE = 'en' # http://www.i18nguy.com/unicode/language-identifiers.html # these languages display right to left LANGUAGES_BIDI = ("he", "ar", "fa", "ur", "fa-ir", "rtl") diff --git a/openedx/features/content_type_gating/tests/test_models.py b/openedx/features/content_type_gating/tests/test_models.py index 59e3bc8c71..e7cb035d6b 100644 --- a/openedx/features/content_type_gating/tests/test_models.py +++ b/openedx/features/content_type_gating/tests/test_models.py @@ -207,7 +207,7 @@ class TestContentTypeGatingConfig(CacheIsolationTestCase): all_configs[CourseLocator('7-True', 'test_course', 'run-None')], { 'enabled': (True, Provenance.org), - 'enabled_as_of': (datetime(2018, 1, 1, 5, tzinfo=pytz.UTC), Provenance.run), + 'enabled_as_of': (datetime(2018, 1, 1, 0, tzinfo=pytz.UTC), Provenance.run), 'studio_override_enabled': (None, Provenance.default), } ) @@ -215,7 +215,7 @@ class TestContentTypeGatingConfig(CacheIsolationTestCase): all_configs[CourseLocator('7-True', 'test_course', 'run-False')], { 'enabled': (False, Provenance.run), - 'enabled_as_of': (datetime(2018, 1, 1, 5, tzinfo=pytz.UTC), Provenance.run), + 'enabled_as_of': (datetime(2018, 1, 1, 0, tzinfo=pytz.UTC), Provenance.run), 'studio_override_enabled': (None, Provenance.default), } ) @@ -223,7 +223,7 @@ class TestContentTypeGatingConfig(CacheIsolationTestCase): all_configs[CourseLocator('7-None', 'test_course', 'run-None')], { 'enabled': (True, Provenance.site), - 'enabled_as_of': (datetime(2018, 1, 1, 5, tzinfo=pytz.UTC), Provenance.run), + 'enabled_as_of': (datetime(2018, 1, 1, 0, tzinfo=pytz.UTC), Provenance.run), 'studio_override_enabled': (None, Provenance.default), } ) diff --git a/openedx/features/course_duration_limits/tests/test_models.py b/openedx/features/course_duration_limits/tests/test_models.py index fb5b22c083..1ec9898b0a 100644 --- a/openedx/features/course_duration_limits/tests/test_models.py +++ b/openedx/features/course_duration_limits/tests/test_models.py @@ -236,21 +236,21 @@ class TestCourseDurationLimitConfig(CacheIsolationTestCase): all_configs[CourseLocator('7-True', 'test_course', 'run-None')], { 'enabled': (True, Provenance.org), - 'enabled_as_of': (datetime(2018, 1, 1, 5, tzinfo=pytz.UTC), Provenance.run), + 'enabled_as_of': (datetime(2018, 1, 1, 0, tzinfo=pytz.UTC), Provenance.run), } ) self.assertEqual( all_configs[CourseLocator('7-True', 'test_course', 'run-False')], { 'enabled': (False, Provenance.run), - 'enabled_as_of': (datetime(2018, 1, 1, 5, tzinfo=pytz.UTC), Provenance.run), + 'enabled_as_of': (datetime(2018, 1, 1, 0, tzinfo=pytz.UTC), Provenance.run), } ) self.assertEqual( all_configs[CourseLocator('7-None', 'test_course', 'run-None')], { 'enabled': (True, Provenance.site), - 'enabled_as_of': (datetime(2018, 1, 1, 5, tzinfo=pytz.UTC), Provenance.run), + 'enabled_as_of': (datetime(2018, 1, 1, 0, tzinfo=pytz.UTC), Provenance.run), } )