Commit 909fe134 by Don Mitchell

Added date_util tests back in and handle null time obj.

parent 28f8910d
...@@ -73,9 +73,9 @@ class CourseDetails(object): ...@@ -73,9 +73,9 @@ class CourseDetails(object):
""" """
Decode the json into CourseDetails and save any changed attrs to the db 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'] 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) descriptor = get_modulestore(course_location).get_item(course_location)
dirty = False dirty = False
......
# 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): ...@@ -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. If None is passed in for dt, an empty string will be returned.
The default value of show_timezone is True. The default value of show_timezone is True.
""" """
if dt is None:
return ""
timezone = "" timezone = ""
if dt is not None and show_timezone: if dt is not None and show_timezone:
if dt.tzinfo is not None: if dt.tzinfo is not None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment