Fix test_import and unicode issues.
Handle unicode in get_course_index
This commit is contained in:
@@ -99,7 +99,7 @@ class ErrorDescriptor(ErrorFields, XModuleDescriptor):
|
||||
|
||||
# real metadata stays in the content, but add a display name
|
||||
field_data = DictFieldData({
|
||||
'error_msg': str(error_msg),
|
||||
'error_msg': unicode(error_msg),
|
||||
'contents': contents,
|
||||
'location': location,
|
||||
'category': 'error'
|
||||
|
||||
@@ -80,7 +80,7 @@ class MongoConnection(object):
|
||||
"""
|
||||
Get the course_index from the persistence mechanism whose id is the given key
|
||||
"""
|
||||
case_regex = r"(?i)^{}$" if ignore_case else r"{}"
|
||||
case_regex = ur"(?i)^{}$" if ignore_case else ur"{}"
|
||||
return self.course_index.find_one(
|
||||
son.SON([
|
||||
(key_attr, re.compile(case_regex.format(getattr(key, key_attr))))
|
||||
|
||||
@@ -438,7 +438,7 @@ class ImportTestCase(BaseCourseTestCase):
|
||||
print("course errors:")
|
||||
|
||||
# Expect to find an error/exception about characters in "®esources"
|
||||
expect = "UnicodeEncodeError"
|
||||
expect = "InvalidKeyError"
|
||||
errors = [
|
||||
(msg.encode("utf-8"), err.encode("utf-8"))
|
||||
for msg, err
|
||||
|
||||
@@ -605,7 +605,7 @@ def policy_key(location):
|
||||
Get the key for a location in a policy file. (Since the policy file is
|
||||
specific to a course, it doesn't need the full location url).
|
||||
"""
|
||||
return '{cat}/{name}'.format(cat=location.category, name=location.name)
|
||||
return u'{cat}/{name}'.format(cat=location.category, name=location.name)
|
||||
|
||||
|
||||
Template = namedtuple("Template", "metadata data children")
|
||||
|
||||
Reference in New Issue
Block a user