Added date_util tests back in and handle null time obj.
This commit is contained in:
@@ -73,9 +73,9 @@ class CourseDetails(object):
|
||||
"""
|
||||
Decode the json into CourseDetails and save any changed attrs to the db
|
||||
"""
|
||||
# # TODO make it an error for this to be undefined & for it to not be retrievable from modulestore
|
||||
# TODO make it an error for this to be undefined & for it to not be retrievable from modulestore
|
||||
course_location = jsondict['course_location']
|
||||
# # Will probably want to cache the inflight courses because every blur generates an update
|
||||
# Will probably want to cache the inflight courses because every blur generates an update
|
||||
descriptor = get_modulestore(course_location).get_item(course_location)
|
||||
|
||||
dirty = False
|
||||
|
||||
20
common/lib/xmodule/xmodule/tests/test_date_utils.py
Normal file
20
common/lib/xmodule/xmodule/tests/test_date_utils.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# Tests for xmodule.util.date_utils
|
||||
|
||||
from nose.tools import assert_equals
|
||||
from xmodule.util import date_utils
|
||||
import datetime
|
||||
from pytz import UTC
|
||||
|
||||
|
||||
def test_get_default_time_display():
|
||||
assert_equals("", date_utils.get_default_time_display(None))
|
||||
test_time = datetime.datetime(1992, 3, 12, 15, 3, 30, tzinfo=UTC)
|
||||
assert_equals(
|
||||
"Mar 12, 1992 at 15:03 UTC",
|
||||
date_utils.get_default_time_display(test_time))
|
||||
assert_equals(
|
||||
"Mar 12, 1992 at 15:03 UTC",
|
||||
date_utils.get_default_time_display(test_time, True))
|
||||
assert_equals(
|
||||
"Mar 12, 1992 at 15:03",
|
||||
date_utils.get_default_time_display(test_time, False))
|
||||
@@ -8,6 +8,8 @@ def get_default_time_display(dt, show_timezone=True):
|
||||
If None is passed in for dt, an empty string will be returned.
|
||||
The default value of show_timezone is True.
|
||||
"""
|
||||
if dt is None:
|
||||
return ""
|
||||
timezone = ""
|
||||
if dt is not None and show_timezone:
|
||||
if dt.tzinfo is not None:
|
||||
|
||||
Reference in New Issue
Block a user