Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes,
in roughly chronological order, most recent first. Add your entries at or near
the top. Include a label indicating the component affected.

Studio: Newly-created courses default to being published on Jan 1, 2030

Studio: Added pagination to the Files & Uploads page.

Blades: Video player improvements:
Expand Down
23 changes: 15 additions & 8 deletions cms/djangoapps/contentstore/tests/test_item.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Tests for items views."""

import json
import datetime
from datetime import datetime
import ddt

from mock import Mock, patch
Expand Down Expand Up @@ -149,6 +149,13 @@ def test_create_item_negative(self):
resp = self.create_xblock(category='problem', boilerplate='nosuchboilerplate.yaml')
self.assertEqual(resp.status_code, 200)

def test_create_with_future_date(self):
self.assertEqual(self.course.start, datetime(2030, 1, 1, tzinfo=UTC))
resp = self.create_xblock(category='chapter')
locator = self.response_locator(resp)
obj = self.get_item_from_modulestore(locator)
self.assertEqual(obj.start, datetime(2030, 1, 1, tzinfo=UTC))


class TestEditItem(ItemTest):
"""
Expand Down Expand Up @@ -214,14 +221,14 @@ def test_date_fields(self):
data={'metadata': {'due': '2010-11-22T04:00Z'}}
)
sequential = self.get_item_from_modulestore(self.seq_locator)
self.assertEqual(sequential.due, datetime.datetime(2010, 11, 22, 4, 0, tzinfo=UTC))
self.assertEqual(sequential.due, datetime(2010, 11, 22, 4, 0, tzinfo=UTC))
self.client.ajax_post(
self.seq_update_url,
data={'metadata': {'start': '2010-09-12T14:00Z'}}
)
sequential = self.get_item_from_modulestore(self.seq_locator)
self.assertEqual(sequential.due, datetime.datetime(2010, 11, 22, 4, 0, tzinfo=UTC))
self.assertEqual(sequential.start, datetime.datetime(2010, 9, 12, 14, 0, tzinfo=UTC))
self.assertEqual(sequential.due, datetime(2010, 11, 22, 4, 0, tzinfo=UTC))
self.assertEqual(sequential.start, datetime(2010, 9, 12, 14, 0, tzinfo=UTC))

def test_delete_child(self):
"""
Expand Down Expand Up @@ -326,7 +333,7 @@ def test_make_draft(self):
published = self.get_item_from_modulestore(self.problem_locator, False)
self.assertIsNone(published.due)
draft = self.get_item_from_modulestore(self.problem_locator, True)
self.assertEqual(draft.due, datetime.datetime(2077, 10, 10, 4, 0, tzinfo=UTC))
self.assertEqual(draft.due, datetime(2077, 10, 10, 4, 0, tzinfo=UTC))

def test_make_public_with_update(self):
""" Update a problem and make it public at the same time. """
Expand All @@ -338,7 +345,7 @@ def test_make_public_with_update(self):
}
)
published = self.get_item_from_modulestore(self.problem_locator, False)
self.assertEqual(published.due, datetime.datetime(2077, 10, 10, 4, 0, tzinfo=UTC))
self.assertEqual(published.due, datetime(2077, 10, 10, 4, 0, tzinfo=UTC))

def test_make_private_with_update(self):
""" Make a problem private and update it at the same time. """
Expand All @@ -357,7 +364,7 @@ def test_make_private_with_update(self):
with self.assertRaises(ItemNotFoundError):
self.get_item_from_modulestore(self.problem_locator, False)
draft = self.get_item_from_modulestore(self.problem_locator, True)
self.assertEqual(draft.due, datetime.datetime(2077, 10, 10, 4, 0, tzinfo=UTC))
self.assertEqual(draft.due, datetime(2077, 10, 10, 4, 0, tzinfo=UTC))

def test_create_draft_with_update(self):
""" Create a draft and update it at the same time. """
Expand All @@ -378,7 +385,7 @@ def test_create_draft_with_update(self):
published = self.get_item_from_modulestore(self.problem_locator, False)
self.assertIsNone(published.due)
draft = self.get_item_from_modulestore(self.problem_locator, True)
self.assertEqual(draft.due, datetime.datetime(2077, 10, 10, 4, 0, tzinfo=UTC))
self.assertEqual(draft.due, datetime(2077, 10, 10, 4, 0, tzinfo=UTC))


@ddt.ddt
Expand Down
4 changes: 1 addition & 3 deletions common/lib/xmodule/xmodule/course_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ class CourseFields(object):
enrollment_start = Date(help="Date that enrollment for this class is opened", scope=Scope.settings)
enrollment_end = Date(help="Date that enrollment for this class is closed", scope=Scope.settings)
start = Date(help="Start time when this module is visible",
# using now(UTC()) resulted in fractional seconds which screwed up comparisons and anyway w/b the
# time of first invocation of this stmt on the server
default=datetime.fromtimestamp(0, UTC()),
default=datetime(2030, 1, 1, tzinfo=UTC()),
scope=Scope.settings)
end = Date(help="Date that this class ends", scope=Scope.settings)
advertised_start = String(help="Date that this course is advertised to start", scope=Scope.settings)
Expand Down
2 changes: 1 addition & 1 deletion common/lib/xmodule/xmodule/modulestore/inheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class InheritanceMixin(XBlockMixin):

start = Date(
help="Start time when this module is visible",
default=datetime.fromtimestamp(0, UTC),
default=datetime(2030, 1, 1, tzinfo=UTC),
scope=Scope.settings
)
due = Date(help="Date that this problem is due by", scope=Scope.settings)
Expand Down
2 changes: 0 additions & 2 deletions common/lib/xmodule/xmodule/modulestore/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ def _create(cls, target_class, **kwargs):
# Write the data to the mongo datastore
new_course = store.create_xmodule(location, metadata=kwargs.get('metadata', None))

new_course.start = datetime.datetime.now(UTC).replace(microsecond=0)

# The rest of kwargs become attributes on the course:
for k, v in kwargs.iteritems():
setattr(new_course, k, v)
Expand Down
14 changes: 11 additions & 3 deletions common/lib/xmodule/xmodule/tests/test_course_module.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
import datetime
from datetime import datetime

from fs.memoryfs import MemoryFS

Expand All @@ -13,7 +13,15 @@
ORG = 'test_org'
COURSE = 'test_course'

NOW = datetime.datetime.strptime('2013-01-01T01:00:00', '%Y-%m-%dT%H:%M:00').replace(tzinfo=UTC())
NOW = datetime.strptime('2013-01-01T01:00:00', '%Y-%m-%dT%H:%M:00').replace(tzinfo=UTC())


class CourseFieldsTestCase(unittest.TestCase):
def test_default_start_date(self):
self.assertEqual(
xmodule.course_module.CourseFields.start.default,
datetime(2030, 1, 1, tzinfo=UTC())
)


class DummySystem(ImportSystem):
Expand Down Expand Up @@ -77,7 +85,7 @@ def setUp(self):
# Needed for test_is_newish
datetime_patcher = patch.object(
xmodule.course_module, 'datetime',
Mock(wraps=datetime.datetime)
Mock(wraps=datetime)
)
mocked_datetime = datetime_patcher.start()
mocked_datetime.now.return_value = NOW
Expand Down
6 changes: 4 additions & 2 deletions common/lib/xmodule/xmodule/tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,11 @@ def test_metadata_no_inheritance(self):
# Check that the child does not inherit a value for due
child = descriptor.get_children()[0]
self.assertEqual(child.due, None)

# Check that the child hasn't started yet
self.assertLessEqual(
child.start,
datetime.datetime.now(UTC())
datetime.datetime.now(UTC()),
child.start
)

def test_metadata_override_default(self):
Expand Down
11 changes: 9 additions & 2 deletions lms/djangoapps/django_comment_client/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from datetime import datetime
from pytz import UTC
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.utils import override_settings
from student.tests.factories import UserFactory, CourseEnrollmentFactory
from django_comment_common.models import Role, Permission
from django_comment_client.tests.factories import RoleFactory
import django_comment_client.utils as utils
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from courseware.tests.tests import TEST_DATA_MONGO_MODULESTORE


class DictionaryTestCase(TestCase):
def test_extract(self):
d = {'cats': 'meow', 'dogs': 'woof'}
Expand Down Expand Up @@ -128,7 +129,13 @@ def assertThreadCorrect(thread, discussion, expected_title): #pylint: disable=C
@override_settings(MODULESTORE=TEST_DATA_MONGO_MODULESTORE)
class CategoryMapTestCase(ModuleStoreTestCase):
def setUp(self):
self.course = CourseFactory.create(org="TestX", number="101", display_name="Test Course")
self.course = CourseFactory.create(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a comment here as to why you needed to override the default and what the assumptions are on the override (i.e., that you needed to make it in the past)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment. @dmitchell, can you verify that it makes sense and is accurate?

org="TestX", number="101", display_name="Test Course",
# This test needs to use a course that has already started --
# discussion topics only show up if the course has already started,
# and the default start date for courses is Jan 1, 2030.
start=datetime(2012, 2, 3, tzinfo=UTC)
)
# Courses get a default discussion topic on creation, so remove it
self.course.discussion_topics = {}
self.course.save()
Expand Down