Merge remote-tracking branch 'origin/release' into dj18-release-merge
Conflicts: common/djangoapps/util/testing.py lms/djangoapps/instructor/views/api.py lms/djangoapps/teams/tests/test_views.py openedx/core/djangoapps/programs/models.py openedx/core/djangoapps/user_api/accounts/tests/test_views.py requirements/edx/github.txt
This commit is contained in:
@@ -417,6 +417,7 @@ class CourseFields(object):
|
||||
)
|
||||
has_children = True
|
||||
checklists = List(
|
||||
help=_("Checklist to Follow When Developing a Course"),
|
||||
scope=Scope.settings,
|
||||
default=[
|
||||
{
|
||||
@@ -787,7 +788,8 @@ class CourseFields(object):
|
||||
"number that you entered when you created the course. To use the course number that you entered when "
|
||||
"you created the course, enter null."
|
||||
),
|
||||
scope=Scope.settings
|
||||
scope=Scope.settings,
|
||||
default=""
|
||||
)
|
||||
|
||||
max_student_enrollments_allowed = Integer(
|
||||
|
||||
@@ -17,7 +17,7 @@ from django.conf import settings
|
||||
if not settings.configured:
|
||||
settings.configure()
|
||||
|
||||
from django.core.cache import get_cache, InvalidCacheBackendError
|
||||
from django.core.cache import caches, InvalidCacheBackendError
|
||||
import django.dispatch
|
||||
import django.utils
|
||||
|
||||
@@ -152,9 +152,9 @@ def create_modulestore_instance(
|
||||
request_cache = None
|
||||
|
||||
try:
|
||||
metadata_inheritance_cache = get_cache('mongo_metadata_inheritance')
|
||||
metadata_inheritance_cache = caches['mongo_metadata_inheritance']
|
||||
except InvalidCacheBackendError:
|
||||
metadata_inheritance_cache = get_cache('default')
|
||||
metadata_inheritance_cache = caches['default']
|
||||
|
||||
if issubclass(class_, MixedModuleStore):
|
||||
_options['create_modulestore_instance'] = create_modulestore_instance
|
||||
@@ -214,7 +214,7 @@ def modulestore():
|
||||
# should be updated to have a setting that enumerates modulestore
|
||||
# wrappers and then uses that setting to wrap the modulestore in
|
||||
# appropriate wrappers depending on enabled features.
|
||||
from ccx.modulestore import CCXModulestoreWrapper # pylint: disable=import-error
|
||||
from lms.djangoapps.ccx.modulestore import CCXModulestoreWrapper
|
||||
_MIXED_MODULESTORE = CCXModulestoreWrapper(_MIXED_MODULESTORE)
|
||||
|
||||
return _MIXED_MODULESTORE
|
||||
|
||||
@@ -15,7 +15,7 @@ from time import time
|
||||
from pymongo.errors import DuplicateKeyError # pylint: disable=unused-import
|
||||
|
||||
try:
|
||||
from django.core.cache import get_cache, InvalidCacheBackendError
|
||||
from django.core.cache import caches, InvalidCacheBackendError
|
||||
DJANGO_AVAILABLE = True
|
||||
except ImportError:
|
||||
DJANGO_AVAILABLE = False
|
||||
@@ -32,6 +32,15 @@ from xmodule.modulestore.split_mongo import BlockKey
|
||||
new_contract('BlockData', BlockData)
|
||||
|
||||
|
||||
def get_cache(alias):
|
||||
"""
|
||||
Return cache for an `alias`
|
||||
|
||||
Note: The primary purpose of this is to mock the cache in test_split_modulestore.py
|
||||
"""
|
||||
return caches[alias]
|
||||
|
||||
|
||||
def round_power_2(value):
|
||||
"""
|
||||
Return value rounded up to the nearest power of 2.
|
||||
|
||||
@@ -13,7 +13,7 @@ import uuid
|
||||
import ddt
|
||||
from contracts import contract
|
||||
from nose.plugins.attrib import attr
|
||||
from django.core.cache import get_cache, InvalidCacheBackendError
|
||||
from django.core.cache import caches, InvalidCacheBackendError
|
||||
|
||||
from openedx.core.lib import tempdir
|
||||
from xblock.fields import Reference, ReferenceList, ReferenceValueDict
|
||||
@@ -934,7 +934,7 @@ class TestCourseStructureCache(SplitModuleTest):
|
||||
def setUp(self):
|
||||
# use the default cache, since the `course_structure_cache`
|
||||
# is a dummy cache during testing
|
||||
self.cache = get_cache('default')
|
||||
self.cache = caches['default']
|
||||
|
||||
# make sure we clear the cache before every test...
|
||||
self.cache.clear()
|
||||
|
||||
@@ -186,6 +186,9 @@ def main():
|
||||
Generate
|
||||
Usage: static_content.py <output_root>
|
||||
"""
|
||||
from django.conf import settings
|
||||
settings.configure()
|
||||
|
||||
args = docopt(main.__doc__)
|
||||
root = path(args['<output_root>'])
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ from datetime import timedelta, datetime
|
||||
from unittest import TestCase
|
||||
|
||||
from django.utils.timezone import UTC
|
||||
from django.utils.translation import ugettext
|
||||
|
||||
from xmodule.course_metadata_utils import (
|
||||
clean_course_key,
|
||||
@@ -105,6 +104,10 @@ class CourseMetadataUtilsTestCase(TestCase):
|
||||
else:
|
||||
raise ValueError("Invalid format string :" + format_string)
|
||||
|
||||
def nop_gettext(text):
|
||||
"""Dummy implementation of gettext, so we don't need Django."""
|
||||
return text
|
||||
|
||||
test_datetime = datetime(1945, 02, 06, 04, 20, 00, tzinfo=UTC())
|
||||
advertised_start_parsable = "2038-01-19 03:14:07"
|
||||
advertised_start_bad_date = "215-01-01 10:10:10"
|
||||
@@ -158,36 +161,34 @@ class CourseMetadataUtilsTestCase(TestCase):
|
||||
# Test parsable advertised start date.
|
||||
# Expect start datetime to be parsed and formatted back into a string.
|
||||
TestScenario(
|
||||
(DEFAULT_START_DATE, advertised_start_parsable, 'DATE_TIME', ugettext, mock_strftime_localized),
|
||||
(DEFAULT_START_DATE, advertised_start_parsable, 'DATE_TIME', nop_gettext, mock_strftime_localized),
|
||||
mock_strftime_localized(Date().from_json(advertised_start_parsable), 'DATE_TIME') + " UTC"
|
||||
),
|
||||
# Test un-parsable advertised start date.
|
||||
# Expect date parsing to throw a ValueError, and the advertised
|
||||
# start to be returned in Title Case.
|
||||
TestScenario(
|
||||
(test_datetime, advertised_start_unparsable, 'DATE_TIME', ugettext, mock_strftime_localized),
|
||||
(test_datetime, advertised_start_unparsable, 'DATE_TIME', nop_gettext, mock_strftime_localized),
|
||||
advertised_start_unparsable.title()
|
||||
),
|
||||
# Test parsable advertised start date from before January 1, 1900.
|
||||
# Expect mock_strftime_localized to throw a ValueError, and the
|
||||
# advertised start to be returned in Title Case.
|
||||
TestScenario(
|
||||
(test_datetime, advertised_start_bad_date, 'DATE_TIME', ugettext, mock_strftime_localized),
|
||||
(test_datetime, advertised_start_bad_date, 'DATE_TIME', nop_gettext, mock_strftime_localized),
|
||||
advertised_start_bad_date.title()
|
||||
),
|
||||
# Test without advertised start date, but with a set start datetime.
|
||||
# Expect formatted datetime to be returned.
|
||||
TestScenario(
|
||||
(test_datetime, None, 'SHORT_DATE', ugettext, mock_strftime_localized),
|
||||
(test_datetime, None, 'SHORT_DATE', nop_gettext, mock_strftime_localized),
|
||||
mock_strftime_localized(test_datetime, 'SHORT_DATE')
|
||||
),
|
||||
# Test without advertised start date and with default start datetime.
|
||||
# Expect TBD to be returned.
|
||||
TestScenario(
|
||||
(DEFAULT_START_DATE, None, 'SHORT_DATE', ugettext, mock_strftime_localized),
|
||||
# Translators: TBD stands for 'To Be Determined' and is used when a course
|
||||
# does not yet have an announced start date.
|
||||
ugettext('TBD')
|
||||
(DEFAULT_START_DATE, None, 'SHORT_DATE', nop_gettext, mock_strftime_localized),
|
||||
'TBD'
|
||||
)
|
||||
]),
|
||||
FunctionTest(course_end_datetime_text, [
|
||||
|
||||
Reference in New Issue
Block a user