diff --git a/cms/djangoapps/contentstore/tests/test_course_settings.py b/cms/djangoapps/contentstore/tests/test_course_settings.py index c1b7a9fa0e..5a9af58427 100644 --- a/cms/djangoapps/contentstore/tests/test_course_settings.py +++ b/cms/djangoapps/contentstore/tests/test_course_settings.py @@ -54,6 +54,7 @@ class CourseDetailsTestCase(CourseTestCase): def test_virgin_fetch(self): details = CourseDetails.fetch(self.course_location) self.assertEqual(details.course_location, self.course_location, "Location not copied into") + self.assertIsNotNone(details.start_date.tzinfo) self.assertIsNone(details.end_date, "end date somehow initialized " + str(details.end_date)) self.assertIsNone(details.enrollment_start, "enrollment_start date somehow initialized " + str(details.enrollment_start)) self.assertIsNone(details.enrollment_end, "enrollment_end date somehow initialized " + str(details.enrollment_end)) @@ -67,7 +68,6 @@ class CourseDetailsTestCase(CourseTestCase): jsondetails = json.dumps(details, cls=CourseSettingsEncoder) jsondetails = json.loads(jsondetails) self.assertTupleEqual(Location(jsondetails['course_location']), self.course_location, "Location !=") - # Note, start_date is being initialized someplace. I'm not sure why b/c the default will make no sense. self.assertIsNone(jsondetails['end_date'], "end date somehow initialized ") self.assertIsNone(jsondetails['enrollment_start'], "enrollment_start date somehow initialized ") self.assertIsNone(jsondetails['enrollment_end'], "enrollment_end date somehow initialized ") @@ -116,11 +116,8 @@ class CourseDetailsViewTest(CourseTestCase): self.compare_details_with_encoding(json.loads(resp.content), details.__dict__, field + str(val)) @staticmethod - def convert_datetime_to_iso(datetime): - if datetime is not None: - return datetime.isoformat("T") - else: - return None + def convert_datetime_to_iso(dt): + return Date().to_json(dt) def test_update_and_fetch(self): details = CourseDetails.fetch(self.course_location) diff --git a/cms/envs/acceptance.py b/cms/envs/acceptance.py index 36616ab257..3b3b823b67 100644 --- a/cms/envs/acceptance.py +++ b/cms/envs/acceptance.py @@ -24,6 +24,7 @@ MODULESTORE_OPTIONS = { 'collection': 'acceptance_modulestore', 'fs_root': TEST_ROOT / "data", 'render_template': 'mitxmako.shortcuts.render_to_string', + 'tz_aware': True } MODULESTORE = { diff --git a/cms/envs/dev.py b/cms/envs/dev.py index eea236f0e2..7a581cfe68 100644 --- a/cms/envs/dev.py +++ b/cms/envs/dev.py @@ -23,6 +23,7 @@ modulestore_options = { 'collection': 'modulestore', 'fs_root': GITHUB_REPO_ROOT, 'render_template': 'mitxmako.shortcuts.render_to_string', + 'tz_aware': True } MODULESTORE = { @@ -64,7 +65,7 @@ REPOS = { }, 'content-mit-6002x': { 'branch': 'master', - #'origin': 'git@github.com:MITx/6002x-fall-2012.git', + # 'origin': 'git@github.com:MITx/6002x-fall-2012.git', 'origin': 'git@github.com:MITx/content-mit-6002x.git', }, '6.00x': { diff --git a/cms/envs/test.py b/cms/envs/test.py index 8a3f9ba158..771a62526f 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -49,6 +49,7 @@ MODULESTORE_OPTIONS = { 'collection': 'test_modulestore', 'fs_root': TEST_ROOT / "data", 'render_template': 'mitxmako.shortcuts.render_to_string', + 'tz_aware': True } MODULESTORE = { @@ -121,7 +122,7 @@ CELERY_RESULT_BACKEND = 'cache' BROKER_TRANSPORT = 'memory' ################### Make tests faster -#http://slacy.com/blog/2012/04/make-your-tests-faster-in-django-1-4/ +# http://slacy.com/blog/2012/04/make-your-tests-faster-in-django-1-4/ PASSWORD_HASHERS = ( 'django.contrib.auth.hashers.SHA1PasswordHasher', 'django.contrib.auth.hashers.MD5PasswordHasher', diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py b/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py index 6332ade04f..66ddd3ecf4 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py @@ -19,7 +19,7 @@ DB = 'test' COLLECTION = 'modulestore' FS_ROOT = DATA_DIR # TODO (vshnayder): will need a real fs_root for testing load_item DEFAULT_CLASS = 'xmodule.raw_module.RawDescriptor' -RENDER_TEMPLATE = lambda t_n, d, ctx=None, nsp='main': '' +RENDER_TEMPLATE = lambda t_n, d, ctx = None, nsp = 'main': '' class TestMongoModuleStore(object): @@ -42,7 +42,8 @@ class TestMongoModuleStore(object): @staticmethod def initdb(): # connect to the db - store = MongoModuleStore(HOST, DB, COLLECTION, FS_ROOT, RENDER_TEMPLATE, default_class=DEFAULT_CLASS) + store = MongoModuleStore(HOST, DB, COLLECTION, FS_ROOT, RENDER_TEMPLATE, + default_class=DEFAULT_CLASS, tz_aware=True) # Explicitly list the courses to load (don't want the big one) courses = ['toy', 'simple'] import_from_xml(store, DATA_DIR, courses) diff --git a/lms/djangoapps/courseware/tests/tests.py b/lms/djangoapps/courseware/tests/tests.py index f037fc6c3e..15a41f4072 100644 --- a/lms/djangoapps/courseware/tests/tests.py +++ b/lms/djangoapps/courseware/tests/tests.py @@ -66,6 +66,7 @@ def mongo_store_config(data_dir): 'collection': 'modulestore_%s' % uuid4().hex, 'fs_root': data_dir, 'render_template': 'mitxmako.shortcuts.render_to_string', + 'tz_aware': True } } } @@ -288,7 +289,7 @@ class PageLoaderTestCase(LoginEnrollmentTestCase): ''' Choose a page in the course randomly, and assert that it loads ''' - # enroll in the course before trying to access pages + # enroll in the course before trying to access pages courses = module_store.get_courses() self.assertEqual(len(courses), 1) course = courses[0] diff --git a/lms/envs/acceptance.py b/lms/envs/acceptance.py index 3b87bb4326..c3da2917ce 100644 --- a/lms/envs/acceptance.py +++ b/lms/envs/acceptance.py @@ -25,6 +25,7 @@ modulestore_options = { 'collection': 'acceptance_modulestore', 'fs_root': TEST_ROOT / "data", 'render_template': 'mitxmako.shortcuts.render_to_string', + 'tz_aware': True } MODULESTORE = { diff --git a/lms/envs/cms/dev.py b/lms/envs/cms/dev.py index e55c6d61b5..f7ac0c4627 100644 --- a/lms/envs/cms/dev.py +++ b/lms/envs/cms/dev.py @@ -22,6 +22,7 @@ modulestore_options = { 'collection': 'modulestore', 'fs_root': DATA_DIR, 'render_template': 'mitxmako.shortcuts.render_to_string', + 'tz_aware': True } MODULESTORE = { diff --git a/lms/envs/dev_mongo.py b/lms/envs/dev_mongo.py index dfbf473b45..1a706cde03 100644 --- a/lms/envs/dev_mongo.py +++ b/lms/envs/dev_mongo.py @@ -20,6 +20,7 @@ MODULESTORE = { 'collection': 'modulestore', 'fs_root': GITHUB_REPO_ROOT, 'render_template': 'mitxmako.shortcuts.render_to_string', + 'tz_aware': True } } }