Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
00bf5e4f
Commit
00bf5e4f
authored
Mar 21, 2014
by
zubiar-arbi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use unicode strings for slug and regex
STUD-1433
parent
05ea675f
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
42 additions
and
13 deletions
+42
-13
cms/djangoapps/contentstore/tests/test_import.py
+20
-0
cms/djangoapps/contentstore/views/course.py
+1
-1
common/lib/xmodule/xmodule/modulestore/store_utilities.py
+2
-2
common/lib/xmodule/xmodule/modulestore/xml_importer.py
+3
-3
common/test/data/2014_Uni/course.xml
+2
-0
common/test/data/2014_Uni/course/2014_Uni.xml
+3
-0
common/test/data/2014_Uni/policies/2014_Uni/policy.json
+2
-0
common/test/data/2014_Uni/policies/assets.json
+2
-0
lms/djangoapps/dashboard/tests/test_sysadmin.py
+7
-7
No files found.
cms/djangoapps/contentstore/tests/test_import.py
View file @
00bf5e4f
# -*- coding: utf-8 -*-
# pylint: disable=E1101
"""
Tests for import_from_xml using the mongo modulestore.
...
...
@@ -77,6 +78,25 @@ class ContentStoreImportTest(ModuleStoreTestCase):
return
module_store
,
content_store
,
course
,
course_location
def
test_unicode_chars_in_course_name_import
(
self
):
"""
# Test that importing course with unicode 'id' and 'display name' doesn't give UnicodeEncodeError
"""
module_store
=
modulestore
(
'direct'
)
target_location
=
Location
([
'i4x'
,
u'Юникода'
,
'unicode_course'
,
'course'
,
u'échantillon'
])
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'2014_Uni'
],
target_location_namespace
=
target_location
)
course
=
module_store
.
get_item
(
target_location
)
self
.
assertIsNotNone
(
course
)
# test that course 'display_name' same as imported course 'display_name'
self
.
assertEqual
(
course
.
display_name
,
u"Φυσικά το όνομα Unicode"
)
def
test_static_import
(
self
):
'''
Stuff in static_import should always be imported into contentstore
...
...
cms/djangoapps/contentstore/views/course.py
View file @
00bf5e4f
...
...
@@ -389,7 +389,7 @@ def create_new_course(request):
# Set a unique wiki_slug for newly created courses. To maintain active wiki_slugs for existing xml courses this
# cannot be changed in CourseDescriptor.
wiki_slug
=
"{0}.{1}.{2}"
.
format
(
dest_location
.
org
,
dest_location
.
course
,
dest_location
.
name
)
wiki_slug
=
u
"{0}.{1}.{2}"
.
format
(
dest_location
.
org
,
dest_location
.
course
,
dest_location
.
name
)
definition_data
=
{
'wiki_slug'
:
wiki_slug
}
modulestore
(
'direct'
)
.
create_and_save_xmodule
(
...
...
common/lib/xmodule/xmodule/modulestore/store_utilities.py
View file @
00bf5e4f
...
...
@@ -12,7 +12,7 @@ def _prefix_only_url_replace_regex(prefix):
To anyone contemplating making this more complicated:
http://xkcd.com/1171/
"""
return
r"""
return
u
r"""
(?x) # flags=re.VERBOSE
(?P<quote>\\?['"]) # the opening quotes
(?P<prefix>{prefix}) # the prefix
...
...
@@ -28,7 +28,7 @@ def _prefix_and_category_url_replace_regex(prefix):
To anyone contemplating making this more complicated:
http://xkcd.com/1171/
"""
return
r"""
return
u
r"""
(?x) # flags=re.VERBOSE
(?P<quote>\\?['"]) # the opening quotes
(?P<prefix>{prefix}) # the prefix
...
...
common/lib/xmodule/xmodule/modulestore/xml_importer.py
View file @
00bf5e4f
...
...
@@ -312,7 +312,7 @@ def import_module(
source_course_location
,
dest_course_location
,
allow_not_found
=
False
,
do_import_static
=
True
):
logging
.
debug
(
'processing import of module {}...'
.
format
(
module
.
location
.
url
()))
logging
.
debug
(
u
'processing import of module {}...'
.
format
(
module
.
location
.
url
()))
if
do_import_static
and
'data'
in
module
.
fields
and
isinstance
(
module
.
fields
[
'data'
],
xblock
.
fields
.
String
):
# we want to convert all 'non-portable' links in the module_data
...
...
@@ -518,13 +518,13 @@ def remap_namespace(module, target_location_namespace):
# If we are importing into a course with a different course_id and wiki_slug is equal to either of these default
# values then remap it so that the wiki does not point to the old wiki.
if
original_location
.
course_id
!=
target_location_namespace
.
course_id
:
original_unique_wiki_slug
=
'{0}.{1}.{2}'
.
format
(
original_unique_wiki_slug
=
u
'{0}.{1}.{2}'
.
format
(
original_location
.
org
,
original_location
.
course
,
original_location
.
name
)
if
module
.
wiki_slug
==
original_unique_wiki_slug
or
module
.
wiki_slug
==
original_location
.
course
:
module
.
wiki_slug
=
'{0}.{1}.{2}'
.
format
(
module
.
wiki_slug
=
u
'{0}.{1}.{2}'
.
format
(
target_location_namespace
.
org
,
target_location_namespace
.
course
,
target_location_namespace
.
name
,
...
...
common/test/data/2014_Uni/course.xml
0 → 100644
View file @
00bf5e4f
<course
url_name=
"2014_Uni"
org=
"Юникода"
course=
"échantillon"
/>
\ No newline at end of file
common/test/data/2014_Uni/course/2014_Uni.xml
0 → 100644
View file @
00bf5e4f
<course
display_name=
"Φυσικά το όνομα Unicode"
>
<wiki
slug=
"Юникода.échantillon.2014_Uni"
/>
</course>
common/test/data/2014_Uni/policies/2014_Uni/policy.json
0 → 100644
View file @
00bf5e4f
{
"course/2014_Uni"
:
{
"tabs"
:
[{
"type"
:
"courseware"
,
"name"
:
"Courseware"
},
{
"type"
:
"course_info"
,
"name"
:
"Course Info"
},
{
"type"
:
"discussion"
,
"name"
:
"Discussion"
},
{
"type"
:
"wiki"
,
"name"
:
"Wiki"
},
{
"type"
:
"progress"
,
"name"
:
"Progress"
}],
"display_name"
:
"
\u
03a6
\u
03c5
\u
03c3
\u
03b9
\u
03ba
\u
03ac
\u
03c4
\u
03bf
\u
03cc
\u
03bd
\u
03bf
\u
03bc
\u
03b1 Unicode"
,
"discussion_topics"
:
{
"General"
:
{
"id"
:
"i4x-
\u
042e
\u
043d
\u
0438
\u
043a
\u
043e
\u
0434
\u
0430-
\u
00e9chantillon-course-2014_Uni"
}}}}
\ No newline at end of file
common/test/data/2014_Uni/policies/assets.json
0 → 100644
View file @
00bf5e4f
{}
\ No newline at end of file
lms/djangoapps/dashboard/tests/test_sysadmin.py
View file @
00bf5e4f
...
...
@@ -159,13 +159,13 @@ class TestSysadmin(SysadminBaseTestCase):
{
'action'
:
'create_user'
,
'student_fullname'
:
'blah'
,
'student_password'
:
'foozor'
,
})
self
.
assertIn
(
_
(
'Must provide username'
),
response
.
content
)
self
.
assertIn
(
_
(
'Must provide username'
),
response
.
content
.
decode
(
'utf-8'
)
)
# no full name
response
=
self
.
client
.
post
(
reverse
(
'sysadmin'
),
{
'action'
:
'create_user'
,
'student_uname'
:
'test_cuser+sysadmin@edx.org'
,
'student_password'
:
'foozor'
,
})
self
.
assertIn
(
_
(
'Must provide full name'
),
response
.
content
)
self
.
assertIn
(
_
(
'Must provide full name'
),
response
.
content
.
decode
(
'utf-8'
)
)
# Test create valid user
self
.
client
.
post
(
reverse
(
'sysadmin'
),
...
...
@@ -190,20 +190,20 @@ class TestSysadmin(SysadminBaseTestCase):
# Try no username
response
=
self
.
client
.
post
(
reverse
(
'sysadmin'
),
{
'action'
:
'del_user'
,
})
self
.
assertIn
(
_
(
'Must provide username'
),
response
.
content
)
self
.
assertIn
(
_
(
'Must provide username'
),
response
.
content
.
decode
(
'utf-8'
)
)
# Try bad usernames
response
=
self
.
client
.
post
(
reverse
(
'sysadmin'
),
{
'action'
:
'del_user'
,
'student_uname'
:
'flabbergast@example.com'
,
'student_fullname'
:
'enigma jones'
,
})
self
.
assertIn
(
_
(
'Cannot find user with email address'
),
response
.
content
)
self
.
assertIn
(
_
(
'Cannot find user with email address'
),
response
.
content
.
decode
(
'utf-8'
)
)
response
=
self
.
client
.
post
(
reverse
(
'sysadmin'
),
{
'action'
:
'del_user'
,
'student_uname'
:
'flabbergast'
,
'student_fullname'
:
'enigma jones'
,
})
self
.
assertIn
(
_
(
'Cannot find user with username'
),
response
.
content
)
self
.
assertIn
(
_
(
'Cannot find user with username'
),
response
.
content
.
decode
(
'utf-8'
)
)
self
.
client
.
post
(
reverse
(
'sysadmin'
),
{
'action'
:
'del_user'
,
...
...
@@ -268,7 +268,7 @@ class TestSysadmin(SysadminBaseTestCase):
self
.
assertIn
(
'{0} test0'
.
format
(
_
(
'Failed in authenticating'
)),
response
.
content
)
self
.
assertIn
(
_
(
'fixed password'
),
response
.
content
)
self
.
assertIn
(
_
(
'fixed password'
),
response
.
content
.
decode
(
'utf-8'
)
)
self
.
assertTrue
(
self
.
client
.
login
(
username
=
'test0'
,
password
=
eamap
.
internal_password
))
...
...
@@ -277,7 +277,7 @@ class TestSysadmin(SysadminBaseTestCase):
self
.
_setstaff_login
()
response
=
self
.
client
.
post
(
reverse
(
'sysadmin'
),
{
'action'
:
'repair_eamap'
,
})
self
.
assertIn
(
_
(
'All ok!'
),
response
.
content
)
self
.
assertIn
(
_
(
'All ok!'
),
response
.
content
.
decode
(
'utf-8'
)
)
def
test_xml_course_add_delete
(
self
):
"""add and delete course from xml module store"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment